public static void Strategy() { CookingMethod cookMethod = new CookingMethod(); Console.WriteLine("What food would you like to cook?"); var food = Console.ReadLine(); cookMethod.SetFood(food); Console.WriteLine("What cooking strategy would you like to use (1-3)?" + "\n Please choise: " + "\n\n 1 - Grilling" + "\n 2 - Oven Baking" + "\n 3 - DeepFrying"); int input = int.Parse(Console.ReadKey().KeyChar.ToString()); switch (input) { case 1: StartCookingWithStrategy(cookMethod, new Grilling()); break; case 2: StartCookingWithStrategy(cookMethod, new OvenBaking()); break; case 3: StartCookingWithStrategy(cookMethod, new DeepFrying()); break; default: Console.WriteLine("Invalid Selection!"); break; } }
public static void Execute() { CookingMethod cookMethod = new CookingMethod(); Console.WriteLine("What food would you like to cook?\n"); var food = Console.ReadLine(); cookMethod.SetFood(food); Console.WriteLine("\nWhat cooking strategy would you like to use?\n"); Console.WriteLine("1 - Grilling"); Console.WriteLine("2 - Oven baking"); Console.WriteLine("3 - Deep frying"); int input = int.Parse(Console.ReadKey().KeyChar.ToString()); switch (input) { case 1: cookMethod.SetCookStrategy(new Grilling()); cookMethod.Cook(); break; case 2: cookMethod.SetCookStrategy(new OvenBaking()); cookMethod.Cook(); break; case 3: cookMethod.SetCookStrategy(new DeepFrying()); cookMethod.Cook(); break; default: Console.WriteLine("Invalid Selection!"); Execute(); break; } Console.ReadKey(); }