public RemoteControl() { onCommands = new Command[7]; offCommands = new Command[7]; Command noCommand = new NoCommand(); for (int i = 0; i < 7; i++) { onCommands[i] = noCommand; offCommands[i] = noCommand; } undoCommand = noCommand; }
public void setCommand(Command command) { slot = command; }
static void Main(string[] args) { Light light = new Light("Any"); Light kitchenLight = new Light("Kitchen"); Light livingRoomLight = new Light("Living room"); Light bedroomLight = new Light("Bedroom"); Command lightONBtn = new LightONCommand(light); Command lightOffBtn = new LightOFFCommand(light); Command kitchenLightON = new LightONCommand(kitchenLight); Command kitchenLightOFF = new LightOFFCommand(kitchenLight); Command livingRoomON = new LightONCommand(livingRoomLight); Command livingRoomOFF = new LightOFFCommand(livingRoomLight); SimpleRemoteControl simpRemoteCntrl = new SimpleRemoteControl(); simpRemoteCntrl.SetCommand(0,lightONBtn,lightOffBtn); simpRemoteCntrl.SetCommand(1, kitchenLightON, kitchenLightOFF); simpRemoteCntrl.SetCommand(2, livingRoomON, livingRoomOFF); simpRemoteCntrl.OnButtonPushed(0); simpRemoteCntrl.OffButtonPushed(0); simpRemoteCntrl.OnButtonPushed(1); simpRemoteCntrl.OffButtonPushed(1); simpRemoteCntrl.OnButtonPushed(2); simpRemoteCntrl.OffButtonPushed(2); CeilingFan ceilingFanLivingRoom = new CeilingFan("Living Room"); Command ceilingFanHighCommand = new CeilingFanHighCommand(ceilingFanLivingRoom); Command ceilingFanOffCommand = new CeilingFanOffCommand(ceilingFanLivingRoom); simpRemoteCntrl.SetCommand(3, ceilingFanHighCommand, ceilingFanOffCommand); simpRemoteCntrl.OnButtonPushed(3); Console.WriteLine("\n Start of macro \n"); Command[] partyCommandsOn = new Command[] { lightONBtn,kitchenLightON,livingRoomON}; Command[] partyCommandsOff = new Command[] {lightOffBtn,kitchenLightOFF,livingRoomOFF }; MacroCommand macroCommandON = new MacroCommand(partyCommandsOn); MacroCommand macroCommandOff = new MacroCommand(partyCommandsOff); simpRemoteCntrl.SetCommand(0, macroCommandON, macroCommandOff); simpRemoteCntrl.OnButtonPushed(); simpRemoteCntrl.OffButtonPushed(); Console.WriteLine(simpRemoteCntrl.ToString()); }
public void SetCommand(int slot,Command onCommand, Command offCommand) { onCommands[slot] = onCommand; offCommands[slot] = offCommand; }
public void OnButtonPushed(int slot) { onCommands[slot].Execute(); undoCommand = onCommands[slot]; }
public void OffButtonPushed(int slot) { offCommands[slot].Execute(); undoCommand = offCommands[slot]; }
public MacroCommand(Command[] commands) { this.commands = commands; }
public void SetCommand(Command command) { this.command = command; }
public void onButtonWasPushed(int slot) { onCommands[slot].execute(); undoCommand = onCommands[slot]; }
public MacroCommand(Command[] listOfCommands) { md = listOfCommands; }
public void Record(string statement) { var command = new Command(_receiver, statement); command.Execute(); StoreCommand(command); }