Ejemplo n.º 1
0
 private static void ShowCertainRecipeFromList(Cookbook cookbook, List <Recipe> recipes)
 {
     ShowRecipeNames(recipes);
     if (recipes.Count > 0)
     {
         int    recipeNumber = AuxiliaryMethod.LoadNumberInRange("\nKterý recept chcete zobrazit?", recipes.Count);
         Recipe recipe       = cookbook.FindRecipeByName(cookbook.Recipes[recipeNumber - 1].Name);
         if (recipe != null)
         {
             RecipeConsoleUtility.ViewRecipe(recipe);
         }
     }
     else
     {
         Console.WriteLine("Nejsou žádné recepty k zobrazení.");
     }
 }
Ejemplo n.º 2
0
        public static void ShowRandomMenu(Cookbook cookbook)
        {
            Dictionary <Category, Recipe> randomMenu = cookbook.GenerateRandomMenu();

            foreach (Category i in Enum.GetValues(typeof(Category)))
            {
                Console.WriteLine($"{ i }:");

                if (randomMenu.ContainsKey(i))
                {
                    RecipeConsoleUtility.ViewRecipe(randomMenu[i]);
                }
                else
                {
                    Console.WriteLine("Recept s touto kategorií není k dispozici.\n");
                }
            }
            AddIngredientsToShoppingList(randomMenu, cookbook);
        }
Ejemplo n.º 3
0
        public static void AddRecipeToCookbook(Cookbook cookbook)
        {
            string endOfEntry = "";

            while (endOfEntry != "n")
            {
                string name = AuxiliaryMethod.LoadStringFromConsole("\nZadejte název receptu:");;
                while (cookbook.Recipes.Any(p => p.Name.ToLower() == name.ToLower()))
                {
                    Console.WriteLine("Recept s tímto názvem již existuje.");
                    name = AuxiliaryMethod.LoadStringFromConsole("\nZadejte název receptu:");
                }
                List <Ingredient> ingredients = RecipeConsoleUtility.CreateListOfIngredients();
                int    numberOfServings       = (int)AuxiliaryMethod.LoadNumberFromConsole("Jaký je počet porcí?");
                string preparation            = AuxiliaryMethod.LoadStringFromConsole("Napište postup přípravy. Jednotlivé řádky můžete oddělit dvěma mezerami.");
                preparation = preparation.Replace("  ", "\n");
                List <Category> categories = SelectCategories();
                cookbook.AddRecipe(name, numberOfServings, preparation, ingredients, categories);
                endOfEntry = AuxiliaryMethod.EnterYesOrNo("Chcete zadat další recept? a/n");
            }
        }
Ejemplo n.º 4
0
 public static void ViewRecipes(Cookbook cookbook)
 {
     {
         cookbook.Recipes.ForEach(x => RecipeConsoleUtility.ViewRecipe(x));
     }
 }