Exemple #1
0
        static void Main(string[] args)
        {
            PlainPizza pizza = new PlainPizza();

            Console.WriteLine("Plain Pizza: " + pizza.GetPrice().ToString());

            HamDecorator moreHam     = new HamDecorator(pizza);
            HamDecorator someMoreHam = new HamDecorator(moreHam);

            Console.WriteLine("Plain Pizza with double extra Ham: " + someMoreHam.GetPrice().ToString());

            BaconDecorator moreBacon = new BaconDecorator(someMoreHam);

            Console.WriteLine("Plain Pizza with double extra Ham with Bacon: " + moreBacon.GetPrice().ToString());

            PepperoniDecorator morePepperoni = new PepperoniDecorator(moreBacon);

            Console.WriteLine("Plain Pizza with double extra Ham with Bacon with Pepperoni: " + morePepperoni.GetPrice().ToString());

            Console.ReadLine();
        }
Exemple #2
0
 public HamDecorator(PlainPizza pizzaToDecorate)
     : base(pizzaToDecorate)
 {
     this.myPrice = 1.49;
 }
Exemple #3
0
 public PepperoniDecorator(PlainPizza pizzaToDecorate)
     : base(pizzaToDecorate)
 {
     this.myPrice = 1.49;
 }