示例#1
0
文件: Program.cs 项目: viesl/Training
        static void Main(string[] args)
        {
            Player      player      = new Player();
            PlayCommand PlayCommand = new PlayCommand();

            player.Invoke(PlayCommand);
            StopCommand dvdStopCommand = new StopCommand();

            player.Invoke(dvdStopCommand);
        }
        public static void Main(string[] args)
        {
            IMoviePlayer  sonyp      = new SonyMoviePlayer();
            ICommand      sonyPause  = new PauseCommand(sonyp);
            ICommand      sonyPlay   = new PlayCommand(sonyp);
            RemoteControl sonyRemote = new RemoteControl();

            sonyRemote.Command = sonyPlay;

            IMoviePlayer  samp      = new SamsungMoviePlayer();
            ICommand      samPause  = new PauseCommand(samp);
            ICommand      samPlay   = new PlayCommand(samp);
            RemoteControl samRemote = new RemoteControl();

            samRemote.Command = samPlay;

            sonyRemote.PressExecute();
            sonyRemote.PressUndo();

            samRemote.PressExecute();
            samRemote.Command = samPause;
            samRemote.PressExecute();
        }