Esempio n. 1
0
 public void Execute()
 {
     _garageDoor.LightOn();
     _garageDoor.Up();
     _garageDoor.Stop();
     _garageDoor.LightOff();
 }
Esempio n. 2
0
 public void Undo()
 {
     _garageDoor.LightOn();
     _garageDoor.Up();
     _garageDoor.Stop();
     _garageDoor.LightOff();
 }
        public void Execute()
        {
            _garageDoor.Up();
            _garageDoor.LightOn();

            Console.WriteLine("Garage door is open");
        }
        public static void Run()
        {
            // Invoker
            RemoteControlWithUndo remoteControl = new RemoteControlWithUndo();

            // Receivers
            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");

            // Set Commands
            remoteControl.SetCommand(0, () => { livingRoomLight.On(); }, () => { livingRoomLight.Off(); });
            remoteControl.SetCommand(1, () => { kitchenLight.On(); }, () => { kitchenLight.Off(); });
            remoteControl.SetCommand(2, () => { ceilingFan.Low(); }, () => { ceilingFan.Off(); });
            remoteControl.SetCommand(3, () => { ceilingFan.Medium(); }, () => { ceilingFan.Off(); });
            remoteControl.SetCommand(4, () => { ceilingFan.High(); }, () => { ceilingFan.Off(); });
            remoteControl.SetCommand(5, () => { garageDoor.Up(); }, () => { garageDoor.Down(); });

            Action stereoOnWithCD = () => { stereo.On(); stereo.SetCd(); stereo.SetVolume(11); };

            remoteControl.SetCommand(6, stereoOnWithCD, () => { stereo.Off(); });

            // Invoke Commands
            Console.WriteLine("==================================================");
            Console.WriteLine("============= Testing Remote Loader  =============");
            Console.WriteLine("==================================================");
            Console.WriteLine();
            Console.WriteLine(remoteControl);
            Console.WriteLine();
            for (int i = 0; i < remoteControl.numberOfSlots; i++)
            {
                remoteControl.OnButtonWasPushed(i);
                remoteControl.OffButtonWasPushed(i);
            }
        }
 public void Execute()
 {
     _garageDoor.Up();
 }
Esempio n. 6
0
 public void Undo()
 {
     _door.Up();
 }
 public void Undo()
 {
     GarageDoor.Up();
 }
Esempio n. 8
0
 public void Excecute()
 {
     _door.Up();
 }
 public void execute()
 {
     garageDoor.Up();
 }
Esempio n. 10
0
 public void undo()
 {
     garageDoor.Up();
 }
Esempio n. 11
0
 public string Execute()
 {
     return(garageDoor.Up());
 }
 public void Execute()
 {
     door.Up();
 }
 public void Execute() => garageDoor.Up();
Esempio n. 14
0
 public void ExecuteCommand()
 {
     _door.Up();
     Console.WriteLine("Garage Door is Open");
 }
Esempio n. 15
0
 public void Execute(object parameter)
 {
     _garageDoor.Up();
 }
 public void Undo() => garageDoor.Up();