Esempio n. 1
0
        /// <summary>
        /// Full loader with 7 slots
        /// </summary>
        public void RunTest()
        {
            RemoteControl remote = new RemoteControl();

            Light      livingRoomLight = new Light("Living Room");
            Light      kitchenLight    = new Light("Kitchen");
            CeilingFan ceilingFan      = new CeilingFan("Living Room");
            GarageDoor garageDoor      = new GarageDoor("");
            Stereo     stereo          = new Stereo("Living Room");
            //Here I create commands, which can be assigned to the remote's buttons
            LightOnCommand  livingRoomLightOn  = new LightOnCommand(livingRoomLight);
            LightOffCommand livingRoomLightOff = new LightOffCommand(livingRoomLight);
            LightOnCommand  kitchenLightOn     = new LightOnCommand(kitchenLight);
            LightOffCommand kitchenLightOff    = new LightOffCommand(kitchenLight);

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

            GarageDoorOpenCommand  garageDoorUp   = new GarageDoorOpenCommand(garageDoor);
            GarageDoorCloseCommand garageDoorDown = new GarageDoorCloseCommand(garageDoor);

            StereoOnWithCDCommand stereoOnWithCD = new StereoOnWithCDCommand(stereo);
            StereoOffCommand      stereoOff      = new StereoOffCommand(stereo);

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

            Console.WriteLine(remote.ToString());

            remote.PushOnButton(0);
            remote.PushOffButton(0);

            remote.PushOnButton(1);
            remote.PushOffButton(1);

            remote.PushOnButton(2);
            remote.PushOffButton(2);

            remote.PushOffButton(1);
            remote.PushUndobutton();

            remote.PushOnButton(3);
            remote.PushOffButton(3);

            remote.PushOnButton(0);
            remote.PushOffButton(0);

            remote.PushOnButton(5);
            remote.PushUndobutton();
            //remote.PushUndobutton();
        }
Esempio n. 2
0
        /// <summary>
        /// [Deprecated] This loader version has only 1 slot
        /// </summary>
        public void RunSimpleTest()
        {
            SimpleRemoteControl remote = new SimpleRemoteControl(); //Invoker

            Light           light    = new Light("Kitchen");        //Receiver
            LightOnCommand  lightOn  = new LightOnCommand(light);   //Concrete Command + setting the receiver, which is passed as a parameter
            LightOffCommand lightOff = new LightOffCommand(light);

            GarageDoor            garageDoor = new GarageDoor("");
            GarageDoorOpenCommand garageUp   = new GarageDoorOpenCommand(garageDoor);

            remote.Command = lightOn; //SetCommand [as it is the invoker]
            remote.ButtonPress();     //Finally Execute [as it is the invoker]

            remote.Command = garageUp;
            remote.ButtonPress();

            remote.Command = lightOff;
            remote.ButtonPress();
        }
Esempio n. 3
0
 public GarageDoorCloseCommand(GarageDoor door)
 {
     _door = door;
 }
Esempio n. 4
0
 public GarageDoorOpenCommand(GarageDoor door)
 {
     _door = door;
 }