Only one angular command can be active at a time. Only one velocity command can be active at a time. #story[1196]
parent
df624a8437
commit
2868f921e2
@ -0,0 +1,27 @@
|
||||
package mock.model.commandFactory;
|
||||
|
||||
import java.util.Observable;
|
||||
|
||||
/**
|
||||
* Used to track the current active observer command. This is to ensure two commands that do similar things do not overlap.
|
||||
*/
|
||||
public class ActiveObserverCommand {
|
||||
private ObserverCommand currentVelocityCommand;
|
||||
private ObserverCommand currentAngularCommand;
|
||||
|
||||
public ActiveObserverCommand() {
|
||||
|
||||
}
|
||||
|
||||
public void changeVelocityCommand(Observable o, ObserverCommand c) {
|
||||
o.deleteObserver(currentVelocityCommand);
|
||||
o.addObserver(c);
|
||||
currentVelocityCommand = c;
|
||||
}
|
||||
|
||||
public void changeAngularCommand(Observable o, ObserverCommand c) {
|
||||
o.deleteObserver(currentAngularCommand);
|
||||
o.addObserver(c);
|
||||
currentAngularCommand = c;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue