コード例 #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 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());
        }
コード例 #3
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();
        }
コード例 #4
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();
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: Codare/DecoratorPattern
        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();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: rezacse/DesignPatterns
        private static void Main()
        {
            Pizza largePizza = new LargePizza();

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


            Console.WriteLine($"Pizza Description: {largePizza.GetDescription()}");
            Console.WriteLine($"Pizza Price: {largePizza.GetPrice()}");

            Console.ReadKey();
        }
コード例 #7
0
ファイル: DecoratorShould.cs プロジェクト: Xeinaemm/Patterns
        public void CreateMediumPizzaWithCheeseHamPeppers()
        {
            IPizza sut = new MediumPizza();

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

            var expected = new MediumPizza
            {
                Description = "Medium Pizza, Cheese, Ham, Peppers"
            };

            Assert.Equal(expected.Description, sut.GetDescription());
        }
コード例 #8
0
        static void Main()
        {
            Pizza largePizza = new LargePizza();

            //Adding Cheese to Large Pizza
            largePizza = new Cheese(largePizza);

            //Adding Ham to Large Pizza
            largePizza = new Ham(largePizza);

            //Adding Peppers to Large
            largePizza = new Peppers(largePizza);

            Console.WriteLine(largePizza.GetDescription());
            Console.WriteLine("{0:C2}", largePizza.CalculatePrice());
            Console.ReadKey();
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: agarwal-peeush/Learning
        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();
        }