Пример #1
0
        public void RunPartyModeTest()
        {
            RemoteControl remote = new RemoteControl();

            Light  light  = new Light("Living room");
            Stereo stereo = new Stereo("Living room");

            LightOnCommand        lightOn  = new LightOnCommand(light);
            StereoOnWithCDCommand stereoOn = new StereoOnWithCDCommand(stereo);

            LightOffCommand  lightOff  = new LightOffCommand(light);
            StereoOffCommand stereoOff = new StereoOffCommand(stereo);

            Command[]    partyOn       = { lightOn, stereoOn };
            Command[]    partyOff      = { lightOff, stereoOff };
            MacroCommand partyOnMacro  = new MacroCommand(partyOn);
            MacroCommand partyOffMacro = new MacroCommand(partyOff);

            remote.SetCommand(0, partyOnMacro, partyOffMacro);
            Console.WriteLine(remote.ToString());
            Console.WriteLine("\n==Pushing macro ON==");
            remote.PushOnButton(0);
            Console.WriteLine("\n==Pushing macro OFF==");
            remote.PushOffButton(0);
        }
Пример #2
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();
        }
 public StereoOnWithCDCommand(Stereo stereo)
 {
     _stereo = stereo;
 }
Пример #4
0
 public StereoOffCommand(Stereo stereo)
 {
     _stereo = stereo;
 }