コード例 #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);
        }
コード例 #2
0
        private static void DriveVehicle(IVehicle vehicle, Driver driver)
        {
            ICommand powerOnCommand  = new PowerOnCommand(vehicle);
            ICommand powerOffCommand = new PowerOffCommand(vehicle);
            ICommand driveCommand    = new DriveCommand(vehicle);
            ICommand stopCommand     = new StopCommand(vehicle);

            driver.ExecuteCommand(powerOnCommand);
            driver.ExecuteCommand(driveCommand);
            driver.ExecuteCommand(stopCommand);
            driver.ExecuteCommand(powerOffCommand);
        }