/// <summary> /// Starting point of strategy design pattern demo /// </summary> public void Initiate() { WriteLine("What food would you like to cook?"); string food = ReadLine(); PrintCookingMethods(); string choice = ReadLine(); if (!int.TryParse(choice, out int cookingMethod)) { throw new ArgumentException("Please enter integer only"); } ICookingStrategy cookingStrategy = CookingMethod.GetCookingStartegy(cookingMethod); cookingStrategy.Cook(food); Thread.Sleep(2000); WriteLine("Food has been cooked successfully"); }
public void AddMeal(Food meal, ICookingStrategy cookingStrategy) => _meals.Add(meal, cookingStrategy);
public Steak(ICookingStrategy cookingStrategy) { this.CookingStrategy = cookingStrategy; }