private IMeal GetMeal(IEnumerable <DietaryReferenceIntake> dris, IEnumerable <Food> foods) { var meal = MealFactory.GetMeal(dris, new FoodIntake[0]); meal.Fill(foods); return(meal); }
public void Meal_Morning_Factory_OK() { Meal obj = MealFactory.CreateMeal(MealType.MORNING); var meal = obj.Display(1); Console.WriteLine(meal); Assert.IsTrue(obj.Name == "Morning"); }
public void Meal_Night_Factory_OK() { Meal obj = MealFactory.CreateMeal(MealType.NIGHT); var meal = obj.Display(1); Console.WriteLine(meal); Assert.IsTrue(obj.Name == "Night"); }
private static void TestFactory() { var factory = new MealFactory(); using (var file = System.IO.File.Create("meals.txt")) using (var writer = new System.IO.StreamWriter(file, System.Text.Encoding.UTF8)) { factory.mealList.ForEach(m => writer.Write(m.ToString())); } }
public override void Execute() { Console.WriteLine("Please enter desired meal name (green salad/hamburger): "); string mealName = Console.ReadLine(); MealFactory factory = new MealFactory(); IMeal meal = factory.CreateMeal(mealName); meal.ShowDescription(); meal.ShowAmountOfCalories(); }
private IMeal FillChildKnapsack(IEnumerable <DietaryReferenceIntake> maxWeight, IEnumerable <FoodIntake> firstFoodIntakes, IEnumerable <FoodIntake> secondFoodIntakes, IEnumerable <Food> foods) { var child = MealFactory.GetMeal(maxWeight, firstFoodIntakes); foreach (var item in secondFoodIntakes) { var random = MyRandom.Next(0, 1); if (random < 0.8) { child.AddFoodIntake(item); } } if (child.FoodIntakesCount == 0) { child.Fill(foods); } return(child); }
static void Main(string[] args) { var mealFactory = new MealFactory(); mealFactory.PrintMeals(); var mediumBurgerMeal = mealFactory.GetMeal("Burger Meal"); mediumBurgerMeal.Serve("medium"); var mediumPizzaMeal = mealFactory.GetMeal("Pizza Meal"); mediumPizzaMeal.Serve("medium"); var largeBurgerMeal = mealFactory.GetMeal("Burger Meal"); largeBurgerMeal.Serve("large"); var largePizzaMeal = mealFactory.GetMeal("Pizza Meal"); largePizzaMeal.Serve("large"); mealFactory.PrintMeals(); }
public void Cook() { if (mornToggle.isOn) { requirements.mealTime = 0; } else if (aftToggle.isOn) { requirements.mealTime = 1; } else { requirements.mealTime = 2; } requirements.competence = compToggle.isOn; requirements.IsHuman = humanToggle.isOn; questionsUI.gameObject.SetActive(false); MealFactory factory = new MealFactory(requirements); IMeal m = factory.Create(); foodName.gameObject.SetActive(true); if (m is Onion) { foodName.text = "It's all Ogre now." + "\n\n\n\n\n\n\n\nPress Enter to play again!"; } else { foodName.text = "Enjoy your " + m.ToString() + "!\n\n\n\n\n\n\nPress Enter to play again!"; } GameObject.Instantiate(Resources.Load(m + "Prefab")); }
public void CreateMeal(string input) { if (this._meal == null) { MealType meal = MealType.NOTAVAILABLE; var validator = new OrderingValidator(); if (validator.isInputValid(input, out meal)) { if (meal != MealType.NOTAVAILABLE) { this._meal = MealFactory.CreateMeal(meal); var listDishes = validator.GetListDishes().OrderBy(x => x).GroupBy(x => x); bool hasError = false; foreach (var item in listDishes) { DishType?currentDishType = validator.GetToDishType(item.Key); int dishRepetition = item.Count(); if (currentDishType != null) { var dish = this._meal.Dishes.Where(x => x.DishType == currentDishType).FirstOrDefault(); if (dishRepetition > 1) { if (dish.HasMultipleOrder()) { dish.HasOrdered = true; dish.Order(dishRepetition); } else { dish = new ErrorDish(); } } else { if (dish != null) { dish.HasOrdered = true; dish.Order(1); } if (currentDishType == DishType.DESERT && meal == MealType.MORNING) { this._meal.Add(new ErrorDish()); } } } else { if (!hasError) { this._meal.Add(new ErrorDish()); } } } ValidOrder(); } else { this._meal = new Meal("Error"); this._meal.Add(new ErrorDish()); } } } }