forked from ZalesskyMaxim/Task1
/
Program.cs
49 lines (41 loc) · 1.36 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Task1.Factory;
namespace Task1
{
class Program
{
static void Main(string[] args)
{
Creator[] creators = new Creator[2];
creators[0] = new CandyCreator();
creators[1] = new ChocolateCreator();
IGift gift = new Gift();
foreach (Creator i in creators)
{
if (i is CandyCreator)
{
gift.Add(i.FactoryMethod("M&M", 80, 105, 125, TypeCandy.Lollipop));
gift.Add(i.FactoryMethod("ChupaChups", 25, 75, 70, TypeCandy.Lollipop));
}
if (i is ChocolateCreator)
{
gift.Add(i.FactoryMethod("Alpen Gold", 100, 115, 250, ChocolateColor.WhiteChocolate));
}
}
gift.Sort();
gift.ShowItems();
Console.WriteLine();
foreach (var items in gift.FindCandyBySugar(20, 110))
{
Console.WriteLine("Название конфеты: {0}, Сахар: {1}", items.name, items.sugar);
}
Console.WriteLine();
Console.WriteLine("Вес подарка: {0}", gift.GiftWeight());
Console.ReadKey();
}
}
}