Or you could try this:
The nice thing about this, for all of your timed commands you only have to define what its doing when its running.
Code:
public abstract class Mechanism extends Subsystem{
public abstract void stop();
}
Code:
public abstract class TimedCommand extends Command{
private Mechanism mechanism;
public TimedCommand(Mechanism mechanism, double time){
super(time);
this.mechanism = mechanism;
requires(mechanism);
}
@Override
protected void execute() {
//do nothing
}
@Override
protected boolean isFinished() {
return isTimedOut();
}
@Override
protected void interrupted() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
protected void end() {
mechanism.stop();
}
}
Code:
public class RunMotor extends TimedCommand{
private static double time = 1.0;
public RunMotor(){
super(RobotMap.SHOOTER, time);
}
@Override
protected void initialize() {
RobotMap.SHOOTER.shoot();
}
}