Exemplo n.º 1
0
        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;
 }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
 public void SetCommand(int slot,Command onCommand, Command offCommand)
 {
     onCommands[slot] = onCommand;
     offCommands[slot] = offCommand;
 }
Exemplo n.º 5
0
 public void OnButtonPushed(int slot)
 {
     onCommands[slot].Execute();
     undoCommand = onCommands[slot];
 }
Exemplo n.º 6
0
 public void OffButtonPushed(int slot)
 {
     offCommands[slot].Execute();
     undoCommand = offCommands[slot];
 }
Exemplo n.º 7
0
 public MacroCommand(Command[] commands)
 {
     this.commands = commands;
 }
Exemplo n.º 8
0
 public void SetCommand(Command command)
 {
     this.command = command;
 }
Exemplo n.º 9
0
 public void onButtonWasPushed(int slot)
 {
     onCommands[slot].execute();
     undoCommand = onCommands[slot];
 }
Exemplo n.º 10
0
 public MacroCommand(Command[] listOfCommands)
 {
     md = listOfCommands;
 }
Exemplo n.º 11
0
 public void Record(string statement)
 {
     var command = new Command(_receiver, statement);
     command.Execute();
     StoreCommand(command);
 }