예제 #1
0
        static void Main(string[] args)
        {
            //LargePizza largePizza = new LargePizza();
            Pizza largePizza = new LargePizza();

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

            //Console.WriteLine(largePizza.Description);
            Console.WriteLine(largePizza.GetDescription());
            Console.WriteLine("{0:C2}", largePizza.CalculateCost());

            Console.ReadKey();
            Console.WriteLine();

            Beverage coffee = new Espresso();

            coffee = new Mocha(coffee);
            coffee = new Mocha(coffee);
            coffee = new Whip(coffee);

            Console.WriteLine(coffee.GetDescription());
            Console.WriteLine("{0:C2}", coffee.Cost());

            Console.ReadKey();
        }
예제 #2
0
        public void CreateMediumPizzaWithCheeseHamPeppersAndCorrectPrice()
        {
            IPizza sut = new MediumPizza();

            sut = new Cheese(sut);
            sut = new Ham(sut);
            sut = new Peppers(sut);

            Assert.Equal(10.25, sut.CalculateCost());
        }
예제 #3
0
        public void Allow_Being_Decorated_With_Cheese_And_Ham_And_Peppers()
        {
            Pizza largePizza = new LargePizza();

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

            Assert.Equal("Large Pizza, Cheese, Ham, Peppers", largePizza.GetDescription());
            Assert.Equal(13.25m, largePizza.CalculateCost());
        }
예제 #4
0
        private static void Main(string[] args)
        {
            Pizza largePizza = new LargePizza();

            largePizza = new Cheese(largePizza);
            largePizza = new Peppers(largePizza);

            Console.WriteLine(largePizza.GetDescription());
            Console.WriteLine(largePizza.CalculateCost().ToString("C"));
            Console.ReadKey();
        }
예제 #5
0
        private static void Main(string[] args)
        {
            Hamburger largeHamburger = new BlueStack();

            largeHamburger = new Cheese(largeHamburger);
            largeHamburger = new Ham(largeHamburger);
            largeHamburger = new Peppers(largeHamburger);

            Console.WriteLine(largeHamburger.GetDescription());
            Console.WriteLine("{0:C2}", largeHamburger.CalculateCost());

            Console.ReadKey();
        }
예제 #6
0
        private static void Main(string[] args)
        {
            Pizza largePizza = new LargePizza();

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

            Console.WriteLine(largePizza.GetDescription());
            Console.WriteLine("{0:C2}", largePizza.CalculateCost());

            Console.ReadLine();
        }
예제 #7
0
        private static void DemoDecoratorPattern()
        {
            #region Without DecoratorPattern
            //LargePizza largePizza = new LargePizza();

            //Console.WriteLine(largePizza.Description);
            //Console.WriteLine("{0:C2}", largePizza.CalculateCost());
            #endregion

            #region With DecoratorPattern
            Pizza largePizza = new LargePizza();
            largePizza = new Cheese(largePizza);
            largePizza = new Ham(largePizza);
            largePizza = new Peppers(largePizza);

            Console.WriteLine(largePizza.GetDescription());
            Console.WriteLine("{0:C2}", largePizza.CalculateCost());
            #endregion

            Console.ReadKey();
        }