You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
519 B
24 lines
519 B
package mock.model.commandFactory;
|
|
|
|
import java.util.Stack;
|
|
|
|
/**
|
|
* Wraps multiple commands into a composite to execute queued commands during a frame.
|
|
*/
|
|
public class CompositeCommand implements Command {
|
|
private Stack<Command> commands;
|
|
|
|
public CompositeCommand() {
|
|
this.commands = new Stack<>();
|
|
}
|
|
|
|
public void addCommand(Command command) {
|
|
commands.push(command);
|
|
}
|
|
|
|
@Override
|
|
public void execute() {
|
|
while(!commands.isEmpty()) commands.pop().execute();
|
|
}
|
|
}
|