예제 #1
0
파일: UsingCommand.cs 프로젝트: mkryuk/DP
        public static void Run()
        {
            // Receiver
            var coffeeMachine = new CoffeeMachine();

            // Create concrete command
            // Add Receiver to the command
            ICommand cappucchinoMaker = new CappuccinoMaker(coffeeMachine);
            ICommand americanoMaker   = new AmericanoMaker(coffeeMachine, 20);

            // Invoker
            var barista = new Barista();

            barista.AddCommand(cappucchinoMaker);
            barista.AddCommand(americanoMaker);
            barista.AddCommand(cappucchinoMaker);

            // Execute all commands
            barista.MakeCoffee();
            Console.WriteLine();

            barista.GetDrinks().ForEach(item =>
            {
                // Get our drinks
                Console.WriteLine("Our drink contains of:");
                item.ForEach(Console.WriteLine);
            });
        }
예제 #2
0
파일: AmericanoMaker.cs 프로젝트: mkryuk/DP
 public AmericanoMaker(CoffeeMachine coffeeMachine, uint sugar = 0)
 {
     _coffeeMachine = coffeeMachine;
     _sugar         = sugar;
 }
예제 #3
0
 public CappuccinoMaker(CoffeeMachine coffeeMachine, uint sugar = 0)
 {
     _coffeeMachine = coffeeMachine;
     _sugar         = sugar;
 }