static void Main(string[] args) { Gift gift = new Gift(); Candy candy = new Candy("jelly",0.02,0.012,Filling.jelly); gift.Add(candy); Cookie cookie = new Cookie("bicquit", 0.1, 0.08,Filling.condensedMilk,Covering.chocolate); gift.Add(cookie); Jujube jujube = new Jujube("jujube", 0.012, 0.017); gift.Add(jujube); Chocolate chocolate = new Chocolate("alyonka", 0.1, 0.09) ; gift.Add(chocolate); Jujube jujube1 = new Jujube(null, 0.012, 0.007); gift.Add(jujube1); Console.WriteLine("In gift is:"); gift.ShowGift(); Console.WriteLine("\nWeight of gift: " + gift.OverallWeight); gift.SortByName(); Console.WriteLine("\nSorted confections: "); gift.ShowGift(); double moreThan=0; double lessThan=0.07; Console.WriteLine("\nFind elements with {0} - {1} sugar:",moreThan,lessThan); ICollection<IGiftItem> find = gift.SearchBySugar(moreThan, lessThan).ToList<IGiftItem>(); foreach (var i in find) i.ShowElement(); }
public static void Main(string[] args) { Candy candy = new Candy(2.2, "ya", 7.4); Lollipop lollipop = new Lollipop(2.2, "me", 5.5, 1.1, "good"); Chocolate chocolate = new Chocolate(2.1, "opl", 0.11, "milk", true, "quad"); //Gift gift = new Gift(new Candy[]{new Candy(1.1,"roflyan",2.1),new Lollipop(2,"asd",2.3,4.3,"der"), }); Gift gift = new Gift(); gift.Add(candy); gift.Add(lollipop); gift.Add(chocolate); Sort.Bubble(gift); Console.WriteLine(gift); }
public void TestSearch() { var gift = new Gift(); gift.Add(new Vzletnaya()); gift.Add(new Vzletnaya()); gift.Add(new Korowka()); gift.Add(new Alenka()); var sugar = new Vzletnaya().SugarWeight; var foundCandies = gift.FindBySugar(sugar, sugar); Assert.IsTrue(foundCandies.TrueForAll((candy) => candy is Vzletnaya)); }
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(); }
public void TestWeight() { var candies = new List <Candy>() { new Vzletnaya(), new Vzletnaya(), new Alenka(), new Korowka() }; var gift = new Gift(); gift.Add(new Vzletnaya()); gift.Add(new Vzletnaya()); gift.Add(new Korowka()); gift.Add(new Alenka()); double expectedCandiesWeight = 0; candies.ForEach((candy) => expectedCandiesWeight += candy.Weight); Assert.AreEqual(gift.Weight, expectedCandiesWeight); gift.Add(new Alenka()); Assert.AreNotEqual(gift.Weight, expectedCandiesWeight); }
static void Main(string[] args) { IConfectionery confectionery1 = new Znichka(); IConfectionery confectionery2 = new Stolichnyye(); IConfectionery confectionery3 = new StroopWaffel(); IConfectionery confectionery4 = new Zemlyanichnyy(); IGift gift = new Gift(); gift.Add(confectionery1); gift.Add(confectionery2); gift.Add(confectionery3); gift.Add(confectionery4); Console.WriteLine("Gift:"); Console.WriteLine(gift); Console.WriteLine("Total weight:"); Console.WriteLine(gift.Weight); Console.WriteLine(); gift.OrderByDescending(x => x.Name); Console.WriteLine("Gift after sorting by name:"); Console.WriteLine(gift); int min = 40; int max = 50; var result = gift.FindBySugarWeight(min, max); IGift resultGift = new Gift(); resultGift.AddRange(result); Console.WriteLine($"Confectioneries with sugar weight between {min} and {max}"); Console.WriteLine(resultGift); Console.ReadKey(); }
static void Main(string[] args) { IGift gift = new Gift(); gift.Add(new ChocoCandy("Аленка", 50, "Шоколадная конфета", 10, NYGift.Core.Enum.Filling.Nuts)); gift.Add(new ChocoCandy("Коммунарка", 20, "Шоколадная конфета", 15, NYGift.Core.Enum.Filling.Nuts)); gift.Add(new JellyCandy("Maoam", 300, "Желейная конфета", 31, NYGift.Core.Enum.Taste.Grape)); gift.Add(new JellyCandy("Maoam", 300, "Желейная конфета", 31, NYGift.Core.Enum.Taste.Cherry)); gift.Add(new JellyCandy("Maoam", 300, "Желейная конфета", 31, NYGift.Core.Enum.Taste.Orange)); gift.Add(new LollipopCandy("Взлетная", 15, "Леденец", 7, NYGift.Core.Enum.Colour.Red)); Console.WriteLine("Детский подарок сформирован"); Console.WriteLine(); gift.GiftAll(); Console.WriteLine(); Console.WriteLine("Конфеты в подарке сортированные по имени: "); gift.SortByName(); foreach (var i in gift.Items) { Console.WriteLine(" {0}, вес: {1}, вид: {2}, содержание сахара: {3}," , i.CandyName, i.WeightOfOne, i.TypeCandy, i.SugarContentinOne); } Console.WriteLine("Вес подарка: {0}", gift.GiftWeight()); Console.WriteLine(); Console.WriteLine("Выбор кофет с содержанием сахара от 10 до 11 г: "); foreach (var items in gift.FindBySugarContain(10, 11)) { Console.WriteLine("{0}, Содержание сахара: {1}", items.CandyName, items.SugarContentinOne); } Console.WriteLine(); Console.WriteLine("press a key..."); Console.ReadKey(); }
/// <summary> /// Adds the items of the gift. /// </summary> protected void AddItems() { _gift.Add(new Candy("Веселые ребята", "YR47583758", 15, CandyFlavor.Cherry, CandyCategory.FruitJelly, new DateTime(2016, 10, 1), 120)); _gift.Add(new Candy("Коммунарка", "KP65454874", 100, CandyFlavor.DarkChocolate, CandyCategory.Chocolate, new DateTime(2016, 08, 15), 156.5)); _gift.Add(new Candy("Юбилейный", "ET12454854", 36.3, CandyFlavor.Stroberry, CandyCategory.Biscuit, new DateTime(2016, 09, 21), 124)); _gift.Add(new Candy("Барбарис", "XV15748787", 18, CandyFlavor.Orange, CandyCategory.Caramel, new DateTime(2016, 06, 30), 239.6)); _gift.Add(new Candy("Спартак", "LH25787878", 100, CandyFlavor.MilkChocolate, CandyCategory.Chocolate, new DateTime(2016, 12, 16), 202.3)); _gift.Add(new Candy("Чародейка", "ND41545448", 20.9, CandyFlavor.Stroberry, CandyCategory.Marshmallow, new DateTime(2016, 07, 5), 299.9)); _gift.Add(new Fruit("Мандарин", "DH12154542", 35.1, new DateTime(2016, 06, 15))); _gift.Add(new Toy("Медвежонок Винни", "JE54544848", 260, new DateTime(2019, 12, 31), ToyColor.Blue)); _gift.Add(new Toy("Машинка", "WT14545454", 250, new DateTime(2019, 12, 31), ToyColor.Welloy)); _gift.Add(new KinderSurprise("Смешарики", "KL454574878", 200, new DateTime(2016, 10, 01), ToyColor.Pink, 360)); _gift.Add(new Box("Теремок", "ZT45485748", 12.5)); }