Exemplo n.º 1
0
        static void Main(string[] args)
        {
            SimpleRemoteControl remote = new SimpleRemoteControl();

            Light      livingRoomLight  = new Light("Living Romm");
            Light      kitchenRoomLight = new Light("kitchen Romm");
            GarageDoor garageDoor       = new GarageDoor("");
            CeilingFan ceilingFan       = new CeilingFan("Living Room");
            Stereo     stereo           = new Stereo("Living Room");

            LightOnCommand  livingRoomLightOn  = new LightOnCommand(livingRoomLight);
            LightOffCommand livingRoomLightOff = new LightOffCommand(livingRoomLight);

            LightOnCommand  kitchenRoomLightOn  = new LightOnCommand(kitchenRoomLight);
            LightOffCommand kitchenRoomLightOff = new LightOffCommand(kitchenRoomLight);

            CeilingFanHighCommand ceilingFanOn  = new CeilingFanHighCommand(ceilingFan);
            CeilingFanOffCommand  ceilingFanOff = new CeilingFanOffCommand(ceilingFan);

            GarageDoorOpenCommand  garageDoorOpenCommand  = new GarageDoorOpenCommand(garageDoor);
            GarageDoorCloseCommand garageDoorCloseCommand = new GarageDoorCloseCommand(garageDoor);

            StereoOnWithCDCommand stereoOnWithCdCommand = new StereoOnWithCDCommand(stereo);
            StereoOffCommand      stereoOffCommand      = new StereoOffCommand(stereo);

            remote.SetCommand(0, livingRoomLightOn, livingRoomLightOff);
            remote.SetCommand(1, kitchenRoomLightOn, kitchenRoomLightOff);
            remote.SetCommand(2, ceilingFanOn, ceilingFanOff);
            remote.SetCommand(3, stereoOnWithCdCommand, stereoOffCommand);

            Console.WriteLine(remote.ToString());

            remote.OnButtonWasPressed(0);
            remote.OffButtonWasPressed(0);

            remote.OnButtonWasPressed(1);
            remote.OffButtonWasPressed(1);

            remote.OnButtonWasPressed(2);
            remote.OffButtonWasPressed(2);

            remote.OnButtonWasPressed(3);
            remote.OffButtonWasPressed(3);


            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            SimpleRemoteControl remote = new SimpleRemoteControl();
            Light    light             = new Light();
            LightOn  lightOn           = new LightOn(light);
            LightOff lightOff          = new LightOff(light);

            remote.SetCommand(0, lightOn, lightOff);
            remote.OnButtonWasPressed(0);
            remote.OffButtonWasPressed(0);

            GarageDoor      door      = new GarageDoor();
            GarageDoorOpen  doorOpen  = new GarageDoorOpen(door);
            GarageDoorClose doorClose = new GarageDoorClose(door);

            remote.SetCommand(1, doorOpen, doorClose);
            remote.OnButtonWasPressed(1);
            remote.OffButtonWasPressed(1);
        }
Exemplo n.º 3
0
        static void Main()
        {
            SimpleRemoteControl remote = new SimpleRemoteControl();
            Light light = new Light();
            LightOnCommand lightOn = new LightOnCommand(light);
            LightOffCommand lightOff = new LightOffCommand(light);

            GarageDoor garageDoor = new GarageDoor();
            GarageDoorOpenCommand garageOpen = new GarageDoorOpenCommand(garageDoor);
            GarageDoorCloseCommand garageClose = new GarageDoorCloseCommand(garageDoor);

            remote.SetCommand(0, lightOn, lightOff);
            remote.OnButtonWasPressed(0);
            remote.OffButtonWasPressed(0);
            remote.UndoButtonWasPressed();

            remote.SetCommand(1, garageOpen, garageClose);
            remote.OnButtonWasPressed(1);
            remote.OffButtonWasPressed(1);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            SimpleRemoteControl remote = new SimpleRemoteControl();
            Light light = new Light();
            LightOn lightOn = new LightOn(light);
            LightOff lightOff = new LightOff(light);

            remote.SetCommand(0, lightOn, lightOff);
            remote.OnButtonWasPressed(0);
            remote.OffButtonWasPressed(0);

            GarageDoor door = new GarageDoor();
            GarageDoorOpen doorOpen = new GarageDoorOpen(door);
            GarageDoorClose doorClose = new GarageDoorClose(door);

            remote.SetCommand(1, doorOpen, doorClose);
            remote.OnButtonWasPressed(1);
            remote.OffButtonWasPressed(1);
        }