public static void Main(string[] args)
        {
            var playstation = new SingleGift("PS4", 650.00m);

            playstation.CalculateTotalPrice();

            Console.WriteLine();

            var rootBox  = new CompositeGift("RootBox", 0);
            var truckToy = new SingleGift("TruckToy", 155.70m);
            var plainToy = new SingleGift("PlainToy", 325.35m);

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

            var childBox   = new CompositeGift("ChildBox", 0);
            var soldierToy = new SingleGift("SoldierToy", 220m);
            var carToy     = new SingleGift("CarToy", 470.99m);

            childBox.Add(soldierToy);
            childBox.Add(carToy);

            rootBox.Add(childBox);

            var rootBoxTotalPrice = rootBox.CalculateTotalPrice();

            Console.WriteLine($"Total price of this composite present is: {rootBoxTotalPrice}");
        }
Пример #2
0
        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);

            Console.WriteLine($"Total price: {rootBox.CalculateTotalPrice()}");
        }
Пример #3
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()}");
        }
Пример #4
0
        public static void Main()
        {
            var telephone = new SingleGift("Samsung", 300);

            telephone.CalculateTotalPrice();

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

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

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

            childBox.Add(soldierToy);

            rootBox.Add(childBox);

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