static void Main(string[] args)
        {
            var light      = new Light();
            var garageDoor = new GarageDoor();

            var ligthCmd      = new LigthOnCommand(light);
            var garageDoorCmd = new GarageDoorOpenCommand(garageDoor);

            var invoker = new RemoteControl();

            invoker.SetCommand(ligthCmd);
            invoker.OnButtonPressed();

            invoker.SetCommand(garageDoorCmd);
            invoker.OnButtonPressed();

            Console.Read();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            RemoteControl remoteControl = new RemoteControl();

            Ligth           ligth           = new Ligth();
            LigthOnCommand  ligthGarageDoor = new LigthOnCommand(ligth);
            LigthOffCommand ligthOffCommand = new LigthOffCommand(ligth);

            GarageDoor             garageDoor             = new GarageDoor(ligth);
            GarageDoorCommandOpen  garageDoorCommandOpen  = new GarageDoorCommandOpen(garageDoor);
            GarageDoorCommandClose garageDoorCommandClose = new GarageDoorCommandClose(garageDoor);

            remoteControl.SetCommand(1, garageDoorCommandOpen, garageDoorCommandClose);
            remoteControl.SetCommand(2, ligthGarageDoor, ligthOffCommand);

            remoteControl.onButtonWasPushed(1);
            remoteControl.onButtonWasPushed(2);

            Console.WriteLine("Hello World!");
        }