Beispiel #1
0
 static void Main(string[] args)
 {
     Light light = new Light();
     Command lightBtn = new LightONCommand(light);
     SimpleRemoteControl simpRemoteCntrl = new SimpleRemoteControl();
     simpRemoteCntrl.SetCommand(lightBtn);
     simpRemoteCntrl.ButtonWasPressed();
 }
        static void Main(string[] args)
        {
            Light               light           = new Light();
            Command             lightBtn        = new LightONCommand(light);
            SimpleRemoteControl simpRemoteCntrl = new SimpleRemoteControl();

            simpRemoteCntrl.SetCommand(lightBtn);
            simpRemoteCntrl.ButtonWasPressed();
        }
Beispiel #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());
        }
        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());
        }