static void AddRecipe(Recipe[] recipes) // using private static variable by creating new objects of the class Recipe { if (Recipe.NumberOfRecipes() < (recipes.Length - 1)) { recipes[Recipe.NumberOfRecipes()] = CreateRecipe(); } else { Console.WriteLine("There is no more space for new recipes. Please delete a recipe to add one"); } }
static void OpenRecipe(Recipe[] recipes) // Opening recipes is not ready yet // LIST OF RECIPES TO BE ADDED { Console.WriteLine("Currently you have {0}/{1} recipes.", Recipe.NumberOfRecipes(), recipes.Length); if (Recipe.NumberOfRecipes() > 0) { int number = ReadInt("Enter a number of a recipe: ", 0, Recipe.NumberOfRecipes()); if (number == 0) { return; } recipes[number - 1].ShowContent(); } Console.ReadKey(); }
static void DeleteRecipe(Recipe[] recipes) { Console.WriteLine("Currently you have {0}/{1} recipes.", Recipe.NumberOfRecipes(), recipes.Length); if (Recipe.NumberOfRecipes() > 0) { int number = ReadInt("Enter a number of a recipe to delete: ", 0, Recipe.NumberOfRecipes()); if (number == 0) { return; } recipes[number - 1] = recipes[Recipe.NumberOfRecipes() - 1]; recipes[Recipe.NumberOfRecipes() - 1] = null; Recipe.Delete(); Console.WriteLine("Recipe number {0} was deleted succesfully.", number); } Console.ReadKey(); }