public IFoodstuff MakeDish(DishesIndex dish, double weight, IFoodstuff dishDressing = null) { try { switch (dish) { case DishesIndex.CaesarSalad: IEnumerable <IFoodstuff> saladIngredients = GetSaladIngredients(weight, dish); return(new CaesarSalad(weight, saladIngredients, dishDressing as CaesarSauce)); case DishesIndex.CaesarSauce: IEnumerable <IFoodstuff> sauceIngredients = GetSauceIngredients(weight, dish); return(new CaesarSauce(weight, sauceIngredients)); default: return(null); } } catch { throw; } }
/// <summary> /// Fire the event "MakeDishOrder". /// </summary> public IFoodstuff OnMakeDishOrder(IChef chef, DishesIndex dish, double weight) { var preparedDish = MakeDishOrder?.Invoke(chef, dish, weight); Console.WriteLine("Готово!"); return(preparedDish); }
private IEnumerable <IFoodstuff> GetSaladIngredients(double weight, DishesIndex dish) { Console.Write($"{dish} будет готов через секунду: "); for (int i = 1; i < 2; i++) { Thread.Sleep(1000); Console.Write($"{i} "); } Console.Write($"\n"); var saladWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_SALAD_PER_100_GRAMS_OF_SALAD); var parmesanWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_PARMESAN_PER_100_GRAMS_OF_SALAD); var breadWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_BREAD_PER_100_GRAMS_OF_SALAD); var garlicWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_GARLIC_PER_100_GRAMS_OF_SALAD); var oliveOilWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_OLIVE_OIL_PER_100_GRAMS_OF_SALAD); var saltWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_SALT_PER_100_GRAMS_OF_SALAD); var blackPepperWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_BLACK_PEPPER_PER_100_GRAMS_OF_SALAD); return(new List <IFoodstuff> { Store.GetLactucaSativa(saladWeight), Store.GetParmesan(parmesanWeight), Store.GetCiabattaBread(breadWeight), Store.GetGarlic(garlicWeight), Store.GetOliveOil(oliveOilWeight), Store.GetSeaSalt(saltWeight), Store.GetBlackPepper(blackPepperWeight) }); }
private IEnumerable <IFoodstuff> GetSauceIngredients(double weight, DishesIndex dish) { Console.Write($"{dish} будет готов через секунду: "); for (int i = 1; i < 2; i++) { Thread.Sleep(1000); Console.Write($"{i} "); } Console.Write($"\n"); var eggYolkWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SauceData.GRAMS_OF_EGG_YOLK_PER_100_GRAMS_OF_SAUCE); var powderWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SauceData.GRAMS_OF_MUSTARD_POWDER_PER_100_GRAMS_OF_SAUCE); var kefirWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SauceData.GRAMS_OF_KEFIR_PER_100_GRAMS_OF_SAUCE); var oliveOilWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SauceData.GRAMS_OF_OLIVE_OIL_PER_100_GRAMS_OF_SAUCE); var saltWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SauceData.GRAMS_OF_SALT_PER_100_GRAMS_OF_SAUCE); var oreganoWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SauceData.GRAMS_OF_OREGANO_PER_100_GRAMS_OF_SAUCE); return(new List <IFoodstuff> { Store.GetEggYolk(eggYolkWeight), Store.GetMustardPowder(powderWeight), Store.GetKefir(kefirWeight), Store.GetOliveOil(oliveOilWeight), Store.GetSeaSalt(saltWeight), Store.GetOregano(oreganoWeight) }); }
public IFoodstuff MakeDishBy(IChef chef, DishesIndex dish, double weight) { try { var sauceWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_CAESAR_SAUCE_PER_100_GRAMS_OF_SALAD); var saladDressing = chef.MakeDish(DishesIndex.CaesarSauce, sauceWeight); return(chef.MakeDish(dish, weight, saladDressing)); } catch { throw; } }