コード例 #1
0
        static void Main(string[] args)
        {
            /*STEP 1*/

            /*AbstractPizza pp = new PlainPizza();
             * pp = new HamDecorator(pp);
             * pp = new BaconDecorator(pp);
             * pp = new PepperoniDecorator(pp);
             * Console.WriteLine(pp);*/

            /*STEP 2 */
            //PizzaFactory pf = new PizzaFactory();
            //Console.WriteLine(pf.MakePizza(new []{"bacon","bacon","bacon"}));


            /*STEP 3*/
            //PizzaOven oven = new PizzaOven();
            //PizzaMan man = new PizzaMan(oven);
            //man.TakeOrder(new []{"bacon","ham"});
            //Console.ReadKey();

            /*STEP 4*/
            PizzaOven oven = new PizzaOven();
            PizzaMan  man  = new PizzaMan(oven);

            man.TakeOrder(new [] { "ham", "bacon", "bacon" }, "beer", 7.50);
            Console.ReadKey();
        }
コード例 #2
0
ファイル: PizzaMan.cs プロジェクト: Bang0123/SWC2sem
 public PizzaMan(PizzaOven pizzaOven)
 {
     PizzaOven = pizzaOven;
     PizzaOven.AddObserver(this);
     Factory = new PizzaFactory();
     PriceStrategy = TimeOfDay.Lunch;
     EveningPriceStrategy = new EveningPriceStrategy();
     LunchPriceStrategy = new LunchPriceStrategy();
     NightPriceStrategy = new NightPriceStrategy();
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: Bang0123/SWC2sem
        static void Main(string[] args)
        {
            AbstractPizza pp = new PlainPizza();
            pp = new HamDecorator(pp);
            pp = new BaconDecorator(pp);
            pp = new PepperoniDecorator(pp);
            Console.WriteLine(pp);


            PizzaFactory pf = new PizzaFactory();
            Console.WriteLine(pf.MakePizza(new[] { "Pepperoni", "Bacon", "Ham" }));
            PizzaOven oven = new PizzaOven();
            PizzaMan newMan = new PizzaMan(oven);
            Console.WriteLine();
            newMan.TakeOrder(new[] { "Pepperoni", "Bacon" });
            newMan.TakeOrder(new[] { "Pepperoni", "Bacon" }, "Cola", 21.0);

            Console.ReadKey();
        }