Example #1
0
        static void Main(string[] args)
        {
            var regularOrder = new RegularOrder();

            Console.WriteLine(regularOrder.CalculateTotalOrderPrice());
            Console.WriteLine();

            var preOrder = new Preorder();

            Console.WriteLine(preOrder.CalculateTotalOrderPrice());
            Console.WriteLine();

            var premiumPreorder = new PremiumPreorder(preOrder);

            Console.WriteLine(premiumPreorder.CalculateTotalOrderPrice());
        }
Example #2
0
        static void Demo()
        {
            var regularOrder = new RegularOrder();

            Console.WriteLine(regularOrder.CalculateTotalOrderPrice());
            Console.WriteLine();

            var preOrder = new Preorder();

            Console.WriteLine(preOrder.CalculateTotalOrderPrice());
            Console.WriteLine();

            var premiumPreorder = new PremiumPreorder(preOrder);

            Console.WriteLine(premiumPreorder.CalculateTotalOrderPrice());
        }
Example #3
0
        private static void Main()
        {
            GuitarComponent regularOrder = new RegularOrder("Cort", 2000);

            Console.WriteLine(regularOrder.CalculateTotalOrderPrice());

            GuitarComponent preorder = new Preorder("Fender", 2300);

            Console.WriteLine(preorder.CalculateTotalOrderPrice());

            Console.WriteLine();

            // As we can see, with the premiumPreorder object we are wrapping the preorder object to which we add an additional behavior.
            GuitarComponent premium  = new PremiumPreorder(preorder);
            GuitarComponent premium2 = new PremiumPreorder(premium);

            Console.WriteLine(premium.CalculateTotalOrderPrice());
            Console.WriteLine(premium.Operation());

            Console.WriteLine();

            Console.WriteLine(premium2.CalculateTotalOrderPrice());
            Console.WriteLine(premium2.Operation());
        }