static void Main(string[] args) { Sweet sweet = new Sweet("Alenka", 450, 51, 520, 0.45); SweetWithFilling sweetwf = new SweetWithFilling("Grilling", 500, 56, 540, 0.5, "Nut", 0.01); Caramel caramel = new Caramel("Chupa-Chups", 440, 55, 440, 0.52); CaramelWithFilling caramelwf = new CaramelWithFilling("Korovka", 510, 59, 490, "Milk", 0.05, 0.55); ChocolateBar chocolateBar = new ChocolateBar("Spartak", 550, 66, 550, 0.55); Truffle truffle = new Truffle("Golden night", 350, 54, 500, 0.5, "Nut", 0.01); Gift gift = new Gift("Christmas Gift", new List <ISweet>()); gift.AddSweet(sweet); gift.AddSweet(sweetwf); gift.AddSweet(caramel); gift.AddSweet(truffle); gift.AddSweet(chocolateBar); gift.AddSweet(caramelwf); gift.RemoveSweet(sweet); gift.AddSweet(sweet); Console.WriteLine("Gift price is (rubles): {0,13}", gift.GetGiftPrice()); Console.WriteLine("______________________________________"); Console.WriteLine("Total weight of gift is (gramm): {0} ", gift.GetWeight()); Console.WriteLine("______________________________________"); Console.WriteLine("Sort by weight:"); foreach (var i in gift.SortByWeight()) { Console.WriteLine("{0,20} \t {1,10}", i.Name, i.Weight); } Console.WriteLine("______________________________________"); Console.WriteLine("Find sweet by sugar: "); foreach (var i in gift.FindSweetBySugar(52, 57)) { Console.WriteLine("{0,25} \t {1,2}", i.Name, i.Sugar); } Console.ReadLine(); }
static void Main(string[] args) { Gift g1 = new Gift(); Caramel c1 = new Caramel("Chupa-chups", 150, 50, 75); Caramel c2 = new CaramelWithFilling("Roshen", 20, 30, 65, TypeCaramelFilling.Banana); Sweet s1 = new Sweet("Choco-lapki", 15, 10, 20); Sweet s2 = new SweetWithFilling("Yarche", 130, 50, 100, TypeSweetFilling.Nut); g1.Add(c1); g1.Add(c2); g1.Add(s1); g1.Add(s2); g1.SortByWeight(); g1.ShowItems(); g1.ShowPrice(); g1.ShowSweetStuffBySugar(); g1.ShowWeight(); Console.ReadLine(); }