Beispiel #1
0
        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();
        }
Beispiel #2
0
 private static void StartCookingWithStrategy(CookingMethod cookMethod, CookStrategy cookStrategy)
 {
     cookMethod.SetCookStrategy(cookStrategy);
     cookMethod.Cook();
 }