package example7_3; /** * Concrete command object used to make the car start up * @author hornick * */ public class CarStartCommand implements Command { private Car cc; // the auto to which this command applies private String name; // the command phrase /** * Constructor - associates this command with a specific automobile * @param cc CarController that this command affects * @param label - the command name to use in UI components */ public CarStartCommand(Car cc, String label ) { this.cc = cc; this.name = label; } @Override public String getCommandName() { return name; } @Override /** * Start the engine */ public boolean execute() { cc.startEngine(); return true; } @Override /** * Stop the engine */ public boolean unexecute() { cc.stopEngine(); return true; } }