static void Main(string[] args)
        {
            RemoteControl remote = new RemoteControl();

            Light light = new Light();

            ICommand lightsOn  = new LightOnCommand(light);
            ICommand lightsOff = new LightOffCommand(light);

            remote.SetCommand(lightsOn);
            remote.pressButton();

            remote.SetCommand(lightsOff);
            remote.pressButton();
        }
示例#2
0
        static void Main(string[] args)
        {
            Light   light = new Light();
            Command c1    = new CommandOff(light);
            Command c2    = new CommandOn(light);

            //
            RemoteControl remote = new RemoteControl();

            remote.pressButton(c1);


            //remote.pressButton(c2);

            Console.ReadKey();
        }