static void Main(string[] args)
        {
            var remoteControl = new Controllers.RemoteControl();

            var livingRoonLight = new Light("Living Room");
            var kitchenLight    = new Light("Kitchen");
            var ceilingFan      = new CeilingFan("Living Room");
            var garageDoor      = new GarageDoor();
            var stereo          = new Stereo("Living Room");

            var livingRoomLightOn  = new LightOnCommand(livingRoonLight);
            var livingRoomLightOff = new LightOffCommand(livingRoonLight);
            var kitchenLightOn     = new LightOnCommand(kitchenLight);
            var kitchenLightOff    = new LightOffCommand(kitchenLight);

            var ceilingFanOn  = new CeilingFanOnCommand(ceilingFan);
            var ceilingFanOff = new CeilingFanOffCommand(ceilingFan);

            var garageDoorUp   = new GarageDoorUpCommand(garageDoor);
            var garageDoorDown = new GarageDoorDownCommand(garageDoor);

            var stereoOnWithCd = new StereoOnWithCdCommand(stereo);
            var stereoOff      = new StereoOffCommand(stereo);

            remoteControl.SetCommand(0, livingRoomLightOn, livingRoomLightOff);
            remoteControl.SetCommand(1, kitchenLightOn, kitchenLightOff);
            remoteControl.SetCommand(2, ceilingFanOn, ceilingFanOff);
            remoteControl.SetCommand(3, stereoOnWithCd, stereoOff);

            Console.WriteLine(remoteControl);

            remoteControl.OnButtonWasPressed(0);
            remoteControl.OffButtonWasPressed(0);
            remoteControl.OnButtonWasPressed(1);
            remoteControl.OffButtonWasPressed(1);
            remoteControl.OnButtonWasPressed(2);
            remoteControl.OffButtonWasPressed(2);
            remoteControl.OnButtonWasPressed(3);
            remoteControl.OffButtonWasPressed(3);

            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            var remoteControl = new Controllers.RemoteControl();

            var livingRoonLight = new Light("Living Room");
            var television      = new Television("Living Room");
            var stereo          = new Stereo("Living Room");
            var hotTub          = new HotTub();

            var lightOn  = new LightOnCommand(livingRoonLight);
            var lightOff = new LightOffCommand(livingRoonLight);

            var televisionOn  = new TelevisionOnCommand(television);
            var televisionOff = new TelevisionOffCommand(television);

            var stereoOn  = new StereoOnCommand(stereo);
            var stereoOff = new StereoOffCommand(stereo);

            var hotTubOn  = new HotTubOnCommand(hotTub);
            var hotTubOff = new HotTubOffCommand(hotTub);

            var partyOn  = new ICommand[] { lightOn, stereoOn, televisionOn, hotTubOn };
            var partyOff = new ICommand[] { lightOff, stereoOff, televisionOff, hotTubOff };

            var partyMacroOn  = new MacroCommand(partyOn);
            var partyMacroOff = new MacroCommand(partyOff);

            remoteControl.SetCommand(0, partyMacroOn, partyMacroOff);

            Console.WriteLine(remoteControl);
            Console.WriteLine("----------Push Macro On----------");
            remoteControl.OnButtonWasPressed(0);
            Console.WriteLine("----------Push Macro Off---------");
            remoteControl.OffButtonWasPressed(0);

            Console.ReadLine();
        }