public static void Main() { SingleGift phone = new SingleGift("Phone", 256); phone.CalculateTotalPrice(); Console.WriteLine(); CompositeGift rootBox = new CompositeGift("RootBox", 0); SingleGift truckToy = new SingleGift("TruckToy", 289); SingleGift plainToy = new SingleGift("PlainToy", 587); rootBox.Add(truckToy); rootBox.Add(plainToy); CompositeGift childBox = new CompositeGift("ChildBox", 0); SingleGift soldierToy = new SingleGift("SoldierToy", 200); childBox.Add(soldierToy); rootBox.Add(childBox); Console.WriteLine($"Total price of this composite present is: {rootBox.CalculateTotalPrice()}"); }
static void Main(string[] args) { var phone = new SingleGift("Phone", 256); phone.CalculateTotalPrice(); Console.WriteLine(); var rootBox = new CompositeGift("RootBox", 0); var truck = new SingleGift("Truck", 289); var toy = new SingleGift("Toy", 587); rootBox.Add(truck); rootBox.Add(toy); var childBox = new CompositeGift("ChildBox", 0); var soldier = new SingleGift("Soldier", 200); childBox.Add(soldier); rootBox.Add(childBox); Console.WriteLine($"Total price of this composite present is: {rootBox.CalculateTotalPrice()}"); }
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()}"); }