private int[] GetIngredients() { bool thatsAll = false; List <int> ingredients = new List <int>(); while (!thatsAll) { UserIO.PrintYellow("Add new ingredient? y/n"); bool answer = UserIO.AskYesNoQ(); if (answer) { Console.Clear(); IngredientManager ingredientManager = new IngredientManager(); ingredientManager.ShowAllIngredients(); Console.WriteLine(); Console.WriteLine("Enter id of ingredient you want to add to your pizza"); int ingredientId = UserIO.GetUserInt(0, ingredientManager.GlobalIngredients.Count - 1); ingredients.Add(ingredientId); UserIO.PrintGreen($"{ingredientManager.GetOneIngredient(ingredientId)} was added as an ingredient"); } else { thatsAll = true; } } return(ingredients.ToArray()); }
public void MakeOrder() { PizzaManager pizzamanager = new PizzaManager(); Pizza_Manager = pizzamanager; IngredientManager ingredientManager = new IngredientManager(); Ingredient_Manager = ingredientManager; Order newOrder = new Order(); bool ordering = true; ItemIndex = 0; while (ordering) { Console.Clear(); ShowCart(newOrder); GetUserInput(newOrder); SetOrder(newOrder); Console.Clear(); ShowCart(newOrder); ItemIndex++; Console.WriteLine("Want some more? y/n"); ordering = UserIO.AskYesNoQ(); } //check if order can be made bool succes = CheckItemsAvailable(newOrder); if (!succes) { UserIO.PrintRed("---The order could not be made!---"); Ingredient_Manager.SetGlobalIngredients(); return; } Ingredient_Manager.UpdateIngredients(); UserIO.PrintGreen("Order was made"); //print factuur Console.ReadLine(); ShowInvoice(newOrder); //store order StoreOrder(newOrder); }
private bool GetValidUserInput() { UserIO.PrintRed("Create new pizza"); Console.WriteLine(); Console.WriteLine("Enter name"); string name = UserIO.GetUserString(); if (CheckIfInList(name)) { Console.WriteLine("Pizza already exists"); return(false); } Console.WriteLine("Enter price for a small pizza"); double priceSmall = UserIO.GetUserDouble(0, 1000); Console.WriteLine("Enter price for a medium pizza"); double priceMedium = UserIO.GetUserDouble(0, 1000); Console.WriteLine("Enter price for a large pizza"); double priceLarge = UserIO.GetUserDouble(0, 1000); Console.WriteLine("choose ingredients"); int[] ingredients = GetIngredients(); Console.WriteLine("Is this a vegetarian pizza? y/n"); bool isVeg = UserIO.AskYesNoQ(); Name = name; PriceSmall = priceSmall; PriceMedium = priceMedium; PriceLarge = priceLarge; Ingredients = ingredients; IsVeg = isVeg; return(true); }