static void Main(string[] args)
        {
            Pizza p = new Ham(new Cheese(new LargePizza())); // L


            Console.WriteLine(p.GetDescription());
            Console.WriteLine(p.CalculateCost());
            Console.ReadKey();
        }
        public void Allow_Being_Decorated_With_Cheese_And_Ham()
        {
            Pizza largePizza = new LargePizza();

            largePizza = new Cheese(largePizza);
            largePizza = new Ham(largePizza);

            Assert.Equal("Large Pizza, Cheese, Ham", largePizza.GetDescription());
            Assert.Equal(11.25m, largePizza.CalculateCost());
        }
Exemple #3
0
        public static string Run()
        {
            Pizza largePizza = new LargePizza();

            // wrap large pizza with our cheese decorator
            largePizza = new Cheese(largePizza);

            // wrap our large cheese pizza with our ham decorator
            largePizza = new Ham(largePizza);

            return($"{largePizza.GetDescription()} cost: {largePizza.CalculateCost():C2}");
        }
Exemple #4
0
        public static void Bake()
        {
            Pizza pizza = new LargePizza();

            Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}");
            pizza = new Ham(pizza);
            Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}");
            pizza = new Cheese(pizza);
            Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}");
            pizza = new Corn(pizza);
            Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}");
            pizza = new Cheese(pizza);
            Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}");
        }