static void Main(string[] args) { InitConsole(); // Frist chose your stove // Let's play Stove forMainMenu = new Stove(); List <Ingredients> forMain = new List <Ingredients>(); forMainMenu.MainMenu(forMain); }
public void MainMenu(List <Ingredients> ingre) { List <Ingredients> ingredients = ingre; int choice; do { menu: Console.Clear(); Console.WriteLine("1. Add new ingredients"); Console.WriteLine("2. Delte ingredients "); Console.WriteLine("3. Show all ingredients"); Console.WriteLine("4. Go to cook"); Console.WriteLine("5. Exit\n\n"); Console.WriteLine("Chose an option : "); string value = Console.ReadLine(); try { choice = int.Parse(value); } catch (FormatException e) { choice = 0; Console.WriteLine("ATTENTION : " + e.Message + "\n\n"); } switch (value) { case "1": Console.Clear(); Console.WriteLine("1. Add new ingredients"); Ingredients iAdd = new Ingredients(); Stove stAdd = new Stove(); stAdd.AddIngredients(iAdd); Console.WriteLine("\n\nPress any key to continue..."); Console.ReadKey(); goto menu; case "2": Console.Clear(); Console.WriteLine("2. Delte ingredients "); Ingredients iRm = new Ingredients(); Stove stRm = new Stove(); stRm.RemoveIngredients(iRm); Console.WriteLine("\n\nPress any key to continue..."); Console.ReadKey(); goto menu; case "3": Console.Clear(); Console.WriteLine("3. Show all ingredients"); Console.WriteLine("\n\nPress any key to continue..."); Console.ReadKey(); goto menu; case "4": Console.Clear(); Console.WriteLine("4. Go to cook"); Console.WriteLine("\n\nPress any key to continue..."); Console.ReadKey(); goto menu; case "5": Console.Clear(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); break; default: Console.WriteLine("Sorry, invalid selection."); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); goto menu; } } while (choice != 5); }