static void Main(string[] args)
        {
            MobileReceiver      aMobile = Mobile.GetAMobile();
            ICommand            command = new TurnMobileOn(aMobile);
            MobileButtonInvoker invoker = new MobileButtonInvoker(command);

            invoker.Press();
            command = new PressHome(aMobile);
            invoker = new MobileButtonInvoker(command);
            invoker.Press();
            command = new PressBack(aMobile);
            invoker = new MobileButtonInvoker(command);
            invoker.Press();
            command = new VolumeUp(aMobile);
            invoker = new MobileButtonInvoker(command);
            invoker.Press();
            invoker.Press();
            invoker.PressBack();
            command = new VolumeDown(aMobile);
            invoker = new MobileButtonInvoker(command);
            invoker.Press();
            command = new TurnMobileOff(aMobile);
            invoker = new MobileButtonInvoker(command);
            invoker.Press();
            invoker.PressBack();
            Console.ReadLine();
        }
示例#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();
        }