Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Pult pult = new Pult();
            TV   tv   = new TV();

            pult.SetCommand(new TVOnCommand(tv));
            pult.PressButton();
            pult.PressUndo();

            Console.Read();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            TV     tv     = new TV();
            Remote remote = new Remote();

            VolumeUp   increaseVolume = new VolumeUp(tv);
            VolumeDown decreaseVolume = new VolumeDown(tv);

            remote.StoreAndExecute(increaseVolume);
            remote.StoreAndExecute(decreaseVolume);
            remote.StoreAndExecute(increaseVolume);
            remote.StoreAndExecute(increaseVolume);
            remote.PrintHistory();
            Console.ReadKey();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Pult pult = new Pult();
            TV   tv   = new TV();

            pult.SetCommand(new TVOnCommand(tv));
            pult.PressButton();
            pult.PressUndo();

            Microwave microwave = new Microwave();

            pult.SetCommand(new MicrowaveCommand(microwave, 1500));
            pult.PressButton();

            Console.ReadLine();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var tv = new TV();

            var remoteControl = new RemoteControlInvoker();

            var tvOnCOmmand  = new TVOnCommand(tv);
            var tvOffCOmmand = new TVOffCommand(tv);

            //Configure commands
            remoteControl.SetCommand(0, tvOnCOmmand);
            remoteControl.SetCommand(1, tvOffCOmmand);


            //Execute commands
            remoteControl.OnButtonPushed(0);
            remoteControl.OnButtonPushed(1);

            Console.ReadKey();
        }
Ejemplo n.º 5
0
        static void Main()
        {
            var tv = new TV();

            var turnOffCommand    = new TurnOffCommand(tv);
            var turnOnCommand     = new TurnOnCommand(tv);
            var volumeUpCommand   = new VolumeUpCommand(tv);
            var volumeDownCommand = new VolumeDownCommand(tv);

            var buttonsCount    = 5;
            var tvRemoteControl = new TVRemoteControl(buttonsCount);

            tvRemoteControl.SetButtonFunction(0, turnOffCommand);
            tvRemoteControl.SetButtonFunction(1, turnOnCommand);
            tvRemoteControl.SetButtonFunction(2, volumeUpCommand);
            tvRemoteControl.SetButtonFunction(3, volumeDownCommand);

            for (int i = 0; i < buttonsCount; i++)
            {
                tvRemoteControl.PressButton(i);
            }
        }
Ejemplo n.º 6
0
 public TVOnCommand(TV tvSet)
 {
     tv = tvSet;
 }
Ejemplo n.º 7
0
 public TVOnCommand(TV tv)
 {
     _tv = tv;
 }
Ejemplo n.º 8
0
 public Facade(Light l, TV t)
 {
     this.l = l;
     this.t = t;
 }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            /*var remote = new SimpleRemoteControl();
             *
             * var light = new Light();
             * var garageDoor = new GarageDoor();
             *
             * var lightOnCommand = new LigthOnCommand(light);
             * var garageOpenCommand = new GarageDoorOpenCommand(garageDoor);
             *
             * remote.SetCommand(lightOnCommand);
             * remote.ButtonWasPressed();
             * remote.SetCommand(garageOpenCommand);
             * remote.ButtonWasPressed();*/

            var remoteControl = new RemoteControl();

            var livigRoomLight = new Light("Living Room");
            var kitchenLight   = new Light("Kitchen");
            var ceilingFan     = new CeilingFan("Living Room");
            var garageDoor     = new GarageDoor("");
            var stereo         = new Stereo("Living Room");

            var livingRoomLightOn  = new LightOnCommand(livigRoomLight);
            var livingRoomLightOff = new LightOffCommand(livigRoomLight);

            var kitchenRoomLightOn  = new LightOnCommand(kitchenLight);
            var kitchenRoomLightOff = new LightOffCommand(kitchenLight);

            var ceilingFanOn  = new CeilingFanOnCommand(ceilingFan);
            var ceilingFanOff = new CeilingFanOffCommand(ceilingFan);

            var garageDoorUp   = new GarageDoorOpenCommand(garageDoor);
            var garageDoorDown = new GarageDoorDownCommand(garageDoor);

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

            remoteControl.SetCommand(0, livingRoomLightOn, livingRoomLightOff);
            remoteControl.SetCommand(1, kitchenRoomLightOn, kitchenRoomLightOff);
            remoteControl.SetCommand(2, ceilingFanOn, ceilingFanOff);
            remoteControl.SetCommand(3, stereoOnWithCD, stereoOff);

            Console.WriteLine(remoteControl);

            remoteControl.OnButtonWasPushed(0);
            remoteControl.OffButtonWasPushed(0);
            remoteControl.OnButtonWasPushed(1);
            remoteControl.OffButtonWasPushed(1);
            remoteControl.OnButtonWasPushed(2);
            remoteControl.OffButtonWasPushed(2);
            remoteControl.OnButtonWasPushed(3);
            remoteControl.OffButtonWasPushed(3);

            Console.WriteLine("-----------------------------------------------------");

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

            var ceilingFanMedium = new CeilingFanMediumCommand(ceilingFan);
            var ceilingFanHigh   = new CeilingFanHighCommand(ceilingFan);

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

            Console.WriteLine("-----------------------------------------------------");

            Console.WriteLine(remoteControl);

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

            remoteControl.OnButtonWasPushed(1);
            Console.WriteLine(remoteControl);
            remoteControl.UndoButtonWasPushed();

            Console.WriteLine("-----------------------------------------------------");

            var tv     = new TV("Living room");
            var hottub = new Hottub();

            var stereoOn = new StereoOnCommand(stereo);
            var tvOn     = new TVOnCommand(tv);
            var hottubOn = new HottubOnCommand(hottub);

            var tvOff     = new TVOffCommand(tv);
            var hottubOff = new HottubOffCommand(hottub);

            ICommand[] partyOn  = { livingRoomLightOn, stereoOn, tvOn, hottubOn };
            ICommand[] partyOff = { livingRoomLightOff, stereoOff, tvOff, hottubOff };

            var partyOnMacro  = new MacroCommand(partyOn);
            var partyOffMacro = new MacroCommand(partyOff);

            remoteControl.SetCommand(0, partyOnMacro, partyOffMacro);

            Console.WriteLine(remoteControl);
            Console.WriteLine("---Pushing Macro On---");
            remoteControl.OnButtonWasPushed(0);
            Console.WriteLine("---Pushing Macro Off---");
            remoteControl.OffButtonWasPushed(0);

            remoteControl.UndoButtonWasPushed();
        }
Ejemplo n.º 10
0
 public VolumeDown(TV tv)
 {
     this.tv = tv;
 }
Ejemplo n.º 11
0
 public VolumeUp(TV tv)
 {
     this.tv = tv;
 }
Ejemplo n.º 12
0
 public TVOffCommand(TV tv)
 {
     _tv = tv;
 }