コード例 #1
0
        static void Main(string[] args)
        {
            SimpleRemoteControl remote = new SimpleRemoteControl();

            Light            light          = new Light();
            SwitchOnCommand  switchOnLight  = new SwitchOnCommand(light);
            SwitchOffCommand switchOffLight = new SwitchOffCommand(light);
            Door             door           = new Door();
            SwitchOnCommand  openDoor       = new SwitchOnCommand(door);
            SwitchOffCommand closeDoor      = new SwitchOffCommand(door);

            remote.SetOnSlot(0, switchOnLight);
            remote.SetOffSlot(0, switchOffLight);
            remote.SetOnSlot(1, openDoor);
            remote.SetOffSlot(1, closeDoor);
            remote.OnButtonWasPressed(0);
            remote.OnButtonWasPressed(1);
            remote.OffButtonWasPressed(0);
            remote.OffButtonWasPressed(1);
            remote.UndoButtonWasPushed();

            Console.ReadKey();
        }