Пример #1
0
        private static void Main(string[] args)
        {
            var userAnswer = true; 
            do
            {
                var input = GetInput();

                const string msg = "Something was wrong, please check the error and try again.";

                try
                {
                    var time = MealTime.GetTime(input);
                    var strategy = time == EnumDishesTime.Morning
                                        ? (IScheduleStrategy) new MorningMeal()
                                        : new NightMeal();

                    var output = new MealManager(strategy, time).Manager(input);

                    var result = String.Empty;

                    if (output.Menu.Any())
                    {
                        output.Menu.ForEach(p =>
                        {
                            result += String.Format("{0}, ", p);
                        });

                        Console.WriteLine("Dishes for " + output.TimeOfday + ": " +
                                          result.Substring(0, result.Count() - 2));
                    }
                    else
                    {
                        throw new ExceptionGeneric("Error: The inserted text is incorrect.");
                    }
                    
                }
                catch (Exception e)
                {
                    ErrorMessage(msg);
                    Console.WriteLine(e.Message);
                }

                if (userAnswer)
                {
                    Console.WriteLine("\n");
                    Console.WriteLine("Seach again? y/n");
                    var screenResponse = Console.ReadLine();
                    userAnswer = true ? screenResponse == "y" : false;
                    Console.Clear();
                }

            } while (userAnswer);

        }
Пример #2
0
 /// <summary>
 /// Method to get the MealPlan
 /// </summary>
 /// <param name="plan"></param>
 /// <returns></returns>
 private static MealPlan MealPlan(IScheduleStrategy schedule, EnumDishesTime dishesTime, string plan)
 {
     var manager = new MealManager(schedule, dishesTime).Manager(plan);
     return manager;
 }