Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Player      player      = new Player();
            PlayCommand PlayCommand = new PlayCommand();

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

            player.Invoke(dvdStopCommand);
        }
Exemplo n.º 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);
        }