Ejemplo n.º 1
0
        static void Main22(string[] args)
        {
            TV       tv          = new TV();                   // receiver
            ICommand tvOnCommand = new TVOnCommand(tv);        // concrete command

            RemoteControl remoteControl = new RemoteControl(); // invoker

            remoteControl.SetCommand(tvOnCommand);

            remoteControl.PressButton();
            remoteControl.PressButtonUndo();

            Console.ReadKey();

            Microwave microwave        = new Microwave();
            ICommand  microwaveCommand = new MicrowaveCommand(microwave);

            remoteControl.SetCommand(microwaveCommand);
            remoteControl.PressButton();
            remoteControl.PressButtonUndo();

            ICommand simpleCommand = new SimpleCommand(microwave.StartCooking);

            simpleCommand.Execute();
        }
Ejemplo n.º 2
0
 public MicrowaveCommand(Microwave microwave)
 {
     _microwave = microwave;
 }