public static void Main()
        {
            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("5oldierToy", 200);

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

            Console.WriteLine($"Total price of this composite present is: {rootBox.CalculateTotalPrice()}");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            SingleGift phone = new SingleGift("Phone", 256);

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

            CompositeGift rootBox = new CompositeGift("RootBox", 0);
            SingleGift    toy     = new SingleGift("Toy", 587);
            SingleGift    truck   = new SingleGift("Truck", 289);

            rootBox.Add(toy);
            rootBox.Add(truck);

            CompositeGift childBox = new CompositeGift("ChildBox", 0);
            SingleGift    soldier  = new SingleGift("Soldier", 200);

            childBox.Add(soldier);
            rootBox.Add(childBox);

            Console.WriteLine($"The total price of the composite present is: {rootBox.CalculateTotalPrice()}");
        }