package mock.model.commandFactory;

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 Queue<Command> commands;

    public CompositeCommand() {
        this.commands = new ArrayDeque<>();
    }

    public void addCommand(Command command) {
        commands.add(command);
    }

    @Override
    public void execute() {
        while(!commands.isEmpty()) commands.remove().execute();
    }
}
