Esempio n. 1
0
        private static void Main(string[] args)
        {
            RemoteControl remoteControl = new RemoteControl();

            Ventilador ventilador = new Ventilador("Sala");

            VentiladorHighCommand highCommand = new VentiladorHighCommand(ventilador);

            VentiladorMediumCommand mediumCommand = new VentiladorMediumCommand(ventilador);

            VentiladorOffCommand offCommand = new VentiladorOffCommand(ventilador);

            remoteControl.SetCommand(0, mediumCommand, offCommand);
            remoteControl.SetCommand(1, highCommand, offCommand);

            remoteControl.OnButtonPushed(0);

            remoteControl.OffButtonPushed(0);

            remoteControl.UndoButtonWasPushed();

            remoteControl.OnButtonPushed(1);
            remoteControl.UndoButtonWasPushed();

            Console.Write(remoteControl.ToString());
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            RemoteControl remoteControl = new RemoteControl();
            #region
            // 
            //Light light = new Light();
            //Light garageDoorLight = new Light();
            //Stereo stereo = new Stereo();
            //// 
            //LightOnCommand lightOnCommand = new LightOnCommand(light);
            //GarageLightOnCommand garageLightOnCommand = new GarageLightOnCommand(garageDoorLight);
            //StereoOnWithCdCommand stereoOnWithCdCommand = new StereoOnWithCdCommand(stereo);

            //LightOffCommand lightOffCommand = new LightOffCommand(light);
            //GarageLightOffCommand garageLightOffCommand = new GarageLightOffCommand(garageDoorLight);
            //StereoOffCommand stereoOffCommand = new StereoOffCommand(stereo);
            ////
            //remoteControl.SetCommand(0, lightOnCommand, lightOffCommand);
            //remoteControl.SetCommand(1, garageLightOnCommand, garageLightOffCommand);
            //remoteControl.SetCommand(2, stereoOnWithCdCommand, stereoOffCommand);
            ////
            //Console.WriteLine(remoteControl);

            //remoteControl.OnButtonWasPushed(0);
            //remoteControl.OffButtonWasPushed(0);
            //Console.WriteLine(remoteControl);
            //remoteControl.UndoButtonWasPushed();
            //remoteControl.OffButtonWasPushed(0);
            //remoteControl.OnButtonWasPushed(0);
            //Console.WriteLine(remoteControl);
            //remoteControl.UndoButtonWasPushed();

            ////remoteControl.OnButtonWasPushed(1);
            ////remoteControl.OffButtonWasPushed(1);
            ////remoteControl.OnButtonWasPushed(2);
            ////remoteControl.OffButtonWasPushed(2);
            #endregion
            var ceilingFan = new CeilingFan();
            var ceilingFanHight = new CeilingFanHightCommand(ceilingFan);
            var ceilingFanMedium = new CeilingFanMediumCommand(ceilingFan);
            var ceilingFanOff = new CeilingFanOffCommand(ceilingFan);

            remoteControl.SetCommand(0, ceilingFanMedium, ceilingFanOff);
            remoteControl.SetCommand(1, ceilingFanHight, ceilingFanOff);

            remoteControl.OnButtonWasPushed(0);
            remoteControl.OffButtonWasPushed(0);
            Console.WriteLine(remoteControl);
            remoteControl.UndoButtonWasPushed();
            remoteControl.OnButtonWasPushed(1);
            Console.WriteLine(remoteControl);
            remoteControl.UndoButtonWasPushed();
            
            Console.ReadKey(true);

        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            RemoteControl remote          = new RemoteControl();
            Light         livingRoomLight = new Light();
            Stereo        stereo          = new Stereo();
            CeilingFan    ceilingFan      = new CeilingFan("Living Room");

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

            StereoOnCommand  stereoOn  = new StereoOnCommand(stereo);
            StereoOffCommand stereoOff = new StereoOffCommand(stereo);

            CeilingFanHighCommand   ceilingFanHigh   = new CeilingFanHighCommand(ceilingFan);
            CeilingFanMediumCommand ceilingFanMedium = new CeilingFanMediumCommand(ceilingFan);
            CeilingFanLowCommand    ceilingFanLow    = new CeilingFanLowCommand(ceilingFan);
            CeilingFanOffCommand    ceilingFanOff    = new CeilingFanOffCommand(ceilingFan);

            Console.WriteLine(remote.ToString());

            remote.SetCommand(0, livingRoomLightOn, livingRoomLightOff);
            remote.SetCommand(1, stereoOn, stereoOff);
            remote.SetCommand(2, ceilingFanHigh, ceilingFanOff);
            remote.SetCommand(3, ceilingFanMedium, ceilingFanOff);
            remote.SetCommand(4, ceilingFanLow, ceilingFanOff);

            Console.WriteLine(remote.ToString());

            //remote.OnButtonWasPushed(0);
            //remote.OnButtonWasPushed(1);
            //remote.OffButtonWasPushed(0);
            //remote.OffButtonWasPushed(1);
            //remote.UndoButtonWasPushed();

            //remote.OnButtonWasPushed(2);
            //remote.OnButtonWasPushed(3);
            //remote.UndoButtonWasPushed();
            //remote.OffButtonWasPushed(2);
            //remote.UndoButtonWasPushed();

            Command[]    onCommands     = { livingRoomLightOn, stereoOn, ceilingFanHigh };
            MacroCommand macroCommandOn = new MacroCommand(onCommands);

            Command[]    offCommands     = { livingRoomLightOff, stereoOff, ceilingFanOff };
            MacroCommand macroCommandOff = new MacroCommand(offCommands);

            remote.SetCommand(5, macroCommandOn, macroCommandOff);

            remote.OnButtonWasPushed(5);
            Console.WriteLine();
            //remote.OffButtonWasPushed(5);
            remote.UndoButtonWasPushed();
        }
Esempio n. 4
0
        public void Undo()
        {
            RemoteControl remoteControl = new RemoteControl();

            Light light = new Light();

            LightOnCommand  lightOn  = new LightOnCommand(light);
            LightOffCommand lightOff = new LightOffCommand(light);

            remoteControl.SetCommand(0, lightOn, lightOff);

            remoteControl.OnButtonPushed(0);
            remoteControl.OffButtonPushed(0);

            remoteControl.UndoButtonWasPushed();

            Console.Write(remoteControl.ToString());
        }