Changed CompositeCommand stack to queue

#story[1096]
main
Connor Taylor-Brown 8 years ago
parent dad4fa57c6
commit e021dd328d

@ -1,23 +1,24 @@
package mock.model.commandFactory;
import java.util.Stack;
import java.util.ArrayDeque;
import java.util.Queue;
/**
* Wraps multiple commands into a composite to execute queued commands during a frame.
*/
public class CompositeCommand implements Command {
private Stack<Command> commands;
private Queue<Command> commands;
public CompositeCommand() {
this.commands = new Stack<>();
this.commands = new ArrayDeque<>();
}
public void addCommand(Command command) {
commands.push(command);
commands.add(command);
}
@Override
public void execute() {
while(!commands.isEmpty()) commands.pop().execute();
while(!commands.isEmpty()) commands.remove().execute();
}
}

@ -64,6 +64,7 @@ public class ControllerServer extends Observable implements Runnable {
BoatActionDecoder boatActionDecoder = new BoatActionDecoder(encodedMessage.getMessageBody());
action = boatActionDecoder.getBoatAction();
// Notify observers of most recent action
this.notifyObservers();
this.setChanged();
}

Loading…
Cancel
Save