Esempio n. 1
0
        static void Main(string[] args)
        {
            var phone = new SingleGift("phone", 256);
            var n     = phone.CalculateTOtalPrice();

            Console.WriteLine(n);

            var rootBox  = new CompositeGift("RootBox", 0);
            var truckToy = new SingleGift("truckToy", 700);

            rootBox.Add(truckToy);

            Console.WriteLine($"Total price is this composite present is {rootBox.CalculateTOtalPrice()}");
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            var phone = new SingleGift("Phone", 256);

            phone.CalculateTotalPrice();
            Console.WriteLine();

            var rootBox  = new CompositeGift("RootBox", 0);
            var truckToy = new SingleGift("TruckToy", 289);
            var plainToy = new SingleGift("PlainToy", 587);

            rootBox.Add(truckToy);
            rootBox.Add(plainToy);

            var childBox   = new CompositeGift("ChildBox", 0);
            var soldierToy = new SingleGift("SoldierToy", 200);

            childBox.Add(soldierToy);
            rootBox.Add(childBox);

            Console.WriteLine($"Total price of this composite present is : {rootBox.CalculateTotalPrice()}");
        }