Пример #1
0
 //Метод добавления блюда
 public void AddDish()
 {
     if (!string.IsNullOrEmpty(SelectedSushiType))
     {
         if (SelectedSushiType.Equals("Унаги"))
         {
             if (!string.IsNullOrEmpty(SushiName))
             {
                 Sushi.Add(new Unagi(SushiName));
             }
             else
             {
                 Sushi.Add(new Unagi());
             }
         }
         else if (SelectedSushiType.Equals("Радуга"))
         {
             if (!string.IsNullOrEmpty(SushiName))
             {
                 Sushi.Add(new Rainbow(SushiName));
             }
             else
             {
                 Sushi.Add(new Rainbow());
             }
         }
         else if (SelectedSushiType.Equals("С Фугу"))
         {
             if (!string.IsNullOrEmpty(SushiName))
             {
                 Sushi.Add(new Fugu(SushiName));
             }
             else
             {
                 Sushi.Add(new Fugu());
             }
         }
         else if (SelectedSushiType.Equals("Хотатэ"))
         {
             if (!string.IsNullOrEmpty(SushiName))
             {
                 Sushi.Add(new Hotate(SushiName));
             }
             else
             {
                 Sushi.Add(new Hotate());
             }
         }
     }
 }
Пример #2
0
 //Метод добавления допингов (приминение паттерна "Декоратор")
 public void AddSupplement()
 {
     if (SelectedDish != null)
     {
         if (!string.IsNullOrEmpty(SelectedSupplement))
         {
             if (SelectedSupplement.Equals("Обернуть лососем"))
             {
                 ExtraSalmon salmon = new ExtraSalmon(SelectedDish);
                 Sushi.Remove(SelectedDish);
                 Sushi.Add(salmon);
                 SelectedDish = salmon;
             }
             else if (SelectedSupplement.Equals("Обернуть тунцом"))
             {
                 ExtraTuna tuna = new ExtraTuna(SelectedDish);
                 Sushi.Remove(SelectedDish);
                 Sushi.Add(tuna);
                 SelectedDish = tuna;
             }
             else if (SelectedSupplement.Equals("Посыпать кунжутом"))
             {
                 SprinkleSesame sesame = new SprinkleSesame(SelectedDish);
                 Sushi.Remove(SelectedDish);
                 Sushi.Add(sesame);
                 SelectedDish = sesame;
             }
             else if (SelectedSupplement.Equals("Глазировать"))
             {
                 Glazing glazing = new Glazing(SelectedDish);
                 Sushi.Remove(SelectedDish);
                 Sushi.Add(glazing);
                 SelectedDish = glazing;
             }
         }
     }
 }