static void Menu(Order order) { var exit = false; //double totalCost = 0; do { System.Console.WriteLine("What kind of Pizza would you like?"); Startup.PrintMenu(); int selectPizza; int selectSize; int selectCrust; //string chosenSize = ""; //string chosenCrust = ""; int.TryParse(Console.ReadLine(), out selectPizza); switch (selectPizza) { case 1: string chosenSize = ""; string chosenCrust = ""; Startup.PrintSizes(); int.TryParse(Console.ReadLine(), out selectSize); switch (selectSize) { case 1: chosenSize = "Small"; break; case 2: chosenSize = "Medium"; break; case 3: chosenSize = "Large"; break; default: System.Console.WriteLine(); System.Console.WriteLine("Uhh... so... a Medium then."); chosenSize = "Medium"; break; } Startup.PrintCrust(); int.TryParse(Console.ReadLine(), out selectCrust); switch (selectCrust) { case 1: chosenCrust = "Thin"; break; case 2: chosenCrust = "Regular"; break; case 3: chosenCrust = "Deepdish"; break; default: System.Console.WriteLine(); System.Console.WriteLine("Uhh... so... a regular crust then."); chosenCrust = "Regular"; break; } System.Console.WriteLine(); System.Console.WriteLine($"Add a {chosenSize} Pepperioni and Sausage Pizza"); System.Console.WriteLine($"with {chosenCrust} crust to your order?"); System.Console.WriteLine("Select 1 for yes"); System.Console.WriteLine("Select 2 for no"); int confirmOrder; int.TryParse(Console.ReadLine(), out confirmOrder); switch (confirmOrder) { case 1: order.CreatePizza(chosenSize, chosenCrust, new List <string> { "Pepperoni", "Sausage" }); break; case 2: break; } break; case 2: System.Console.WriteLine(); System.Console.WriteLine("Eww... No man you don't want to order that"); System.Console.WriteLine("You want to go back and select 1 instead."); System.Console.WriteLine("You can thank us later!"); //System.Console.WriteLine(); break; case 3: Startup.PrintSizes(); int.TryParse(Console.ReadLine(), out selectSize); chosenSize = ""; chosenCrust = ""; switch (selectSize) { case 1: chosenSize = "Small"; break; case 2: chosenSize = "Medium"; break; case 3: chosenSize = "Large"; break; default: System.Console.WriteLine(); System.Console.WriteLine("Uhh... so... a Medium then."); chosenSize = "Medium"; break; } Startup.PrintCrust(); int.TryParse(Console.ReadLine(), out selectCrust); switch (selectCrust) { case 1: chosenCrust = "Thin"; break; case 2: chosenCrust = "Regular"; break; case 3: chosenCrust = "Deepdish"; break; default: System.Console.WriteLine(); System.Console.WriteLine("Uhh... so... a regular crust then."); chosenCrust = "Regular"; break; } System.Console.WriteLine(); System.Console.WriteLine($"Add a {chosenSize} Pineapple and Ham Pizza"); System.Console.WriteLine($"with {chosenCrust} crust to your order?"); System.Console.WriteLine("Select 1 for yes"); System.Console.WriteLine("Select 2 for no"); //int confirmOrder; int.TryParse(Console.ReadLine(), out confirmOrder); switch (confirmOrder) { case 1: order.CreatePizza(chosenSize, chosenCrust, new List <string> { "Pineapple", "Ham" }); break; case 2: break; } break; case 4: Startup.PrintSizes(); int.TryParse(Console.ReadLine(), out selectSize); List <string> customToppings = new List <string>(); chosenSize = ""; chosenCrust = ""; switch (selectSize) { case 1: chosenSize = "Small"; break; case 2: chosenSize = "Medium"; break; case 3: chosenSize = "Large"; break; default: System.Console.WriteLine(); System.Console.WriteLine("Uhh... so... a Medium then."); chosenSize = "Medium"; break; } Startup.PrintCrust(); int.TryParse(Console.ReadLine(), out selectCrust); switch (selectCrust) { case 1: chosenCrust = "Thin"; break; case 2: chosenCrust = "Regular"; break; case 3: chosenCrust = "Deepdish"; break; default: System.Console.WriteLine(); System.Console.WriteLine("Uhh... so... a regular crust then."); chosenCrust = "Regular"; break; } bool doneToppings = false; int numberOfToppings = 0; System.Console.WriteLine("Which Toppings would you like?"); do { int selectTopping; System.Console.WriteLine(); System.Console.WriteLine("Choose up to five toppings"); System.Console.WriteLine($"You have {numberOfToppings} so far"); Startup.PrintToppings(); int.TryParse(Console.ReadLine(), out selectTopping); switch (selectTopping) { case 1: customToppings.Add("Pepperoni"); numberOfToppings = 1 + numberOfToppings; break; case 2: customToppings.Add("Sausage"); numberOfToppings = 1 + numberOfToppings; break; case 3: customToppings.Add("Pineapple"); numberOfToppings = 1 + numberOfToppings; break; case 4: customToppings.Add("Ham"); numberOfToppings = 1 + numberOfToppings; break; case 5: customToppings.Add("Bacon"); numberOfToppings = 1 + numberOfToppings; break; case 6: if (numberOfToppings > 1) { doneToppings = true; } else { System.Console.WriteLine(); System.Console.WriteLine("C'mon man, you need at least two toppings"); System.Console.WriteLine("to make a good pizza."); } break; default: System.Console.WriteLine(); System.Console.WriteLine("Sorry I didn't understand that."); break; } }while(!doneToppings && numberOfToppings < 5); System.Console.WriteLine(); System.Console.WriteLine($"Add a {chosenSize} Custom Pizza"); System.Console.WriteLine($"with {chosenCrust} crust to your order?"); System.Console.WriteLine("Select 1 for yes"); System.Console.WriteLine("Select 2 for no"); //int confirmOrder; int.TryParse(Console.ReadLine(), out confirmOrder); switch (confirmOrder) { case 1: order.CreatePizza(chosenSize, chosenCrust, customToppings); break; case 2: break; } break; case 5: DisplayCart(order); break; case 6: int orderSize = order.Pizzas.Count; if (orderSize > 0) { System.Console.WriteLine("Which pizza do you want to remove?"); DisplayCart(order); int selectRemove; //System.Console.WriteLine(orderSize); int.TryParse(Console.ReadLine(), out selectRemove); if (selectRemove <= orderSize && selectRemove > 0) { order.DestroyPizza(selectRemove); } else { System.Console.WriteLine(); System.Console.WriteLine("Sorry we didn't understand that."); } } else { System.Console.WriteLine(); System.Console.WriteLine("You need to order a pizza before you can remove one."); } break; case 7: var fmw = new FileManager(); fmw.Write(order); break; case 8: System.Console.WriteLine("goodbye!"); exit = true; break; case 9: var fmr = new FileManager(); DisplayCart(fmr.Read()); break; } } while (!exit); }
static void Menu2(Order cart, Store store) { var exit = false; var pr = new PizzaRepository(); do { Startup.InitialMenu(); int sizesel; int crustsel; int select; int.TryParse(Console.ReadLine(), out select); switch (select) { case 1: string size = ""; string crust = ""; Startup.SizeMenu(); int.TryParse(Console.ReadLine(), out sizesel); switch (sizesel) { case 1: size = "small"; break; case 2: size = "medium"; break; case 3: size = "large"; break; } crust = "regular"; var pizza = cart.CreatePizza(size, crust, new List <string> { "cheese" }, "cheese pizza"); System.Console.WriteLine($"added a {size} Cheese Pizza"); System.Console.WriteLine(); //pr.Create(pizza); break; case 2: size = ""; Startup.SizeMenu(); int.TryParse(Console.ReadLine(), out sizesel); switch (sizesel) { case 1: size = "small"; break; case 2: size = "medium"; break; case 3: size = "large"; break; } crust = "regular"; pizza = cart.CreatePizza(size, crust, new List <string> { "pepperoni", "cheese" }, "pepperoni pizza"); System.Console.WriteLine($"added a {size} Pepperoni Pizza"); System.Console.WriteLine(); break; case 3: size = ""; Startup.SizeMenu(); int.TryParse(Console.ReadLine(), out sizesel); switch (sizesel) { case 1: size = "small"; break; case 2: size = "medium"; break; case 3: size = "large"; break; } crust = "regular"; pizza = cart.CreatePizza(size, crust, new List <string> { "hawaiian", "cheese" }, "hawaiian"); System.Console.WriteLine($"added a {size} Hawaiian Pizza"); System.Console.WriteLine(); break; case 4: Startup.SizeMenu(); int.TryParse(Console.ReadLine(), out sizesel); //string topping1 = ""; //string topping2 = ""; List <string> CustomPizzaToppings = new List <string>(); CustomPizzaToppings.Add("cheese"); size = ""; switch (sizesel) { case 1: size = "small"; break; case 2: size = "medium"; break; case 3: size = "large"; break; } //^^Size Selection crust = ""; Startup.CrustMenu(); int.TryParse(Console.ReadLine(), out crustsel); switch (crustsel) { case 1: crust = "regular"; break; case 2: crust = "stuffed"; break; case 3: crust = "flatbread"; break; case 4: crust = "thin"; break; } //^^Crust Selection int TotalToppings = 0; var end = false; System.Console.WriteLine(); do { int toppingsel; Startup.ToppingMenu(); int.TryParse(Console.ReadLine(), out toppingsel); switch (toppingsel) { case 1: CustomPizzaToppings.Add("pepperoni"); TotalToppings = 1 + TotalToppings; break; case 2: CustomPizzaToppings.Add("sausage"); TotalToppings = 1 + TotalToppings; break; case 3: CustomPizzaToppings.Add("mushroom"); TotalToppings = 1 + TotalToppings; break; case 4: CustomPizzaToppings.Add("bacon"); TotalToppings = 1 + TotalToppings; break; case 5: CustomPizzaToppings.Add("anchovies"); TotalToppings = 1 + TotalToppings; break; case 6: CustomPizzaToppings.Add("olives"); TotalToppings = 1 + TotalToppings; break; case 7: CustomPizzaToppings.Add("onion"); TotalToppings = 1 + TotalToppings; break; case 8: CustomPizzaToppings.Add("chicken"); TotalToppings = 1 + TotalToppings; break; case 9: if (TotalToppings >= 2) { end = true; } else { System.Console.WriteLine("Please select at least two toppings, otherwise choose from the preset options"); } break; } } while (TotalToppings < 5 && end == false); //^^Topping Selection pizza = cart.CreatePizza(size, crust, CustomPizzaToppings, "custom pizza"); System.Console.WriteLine($"added a {size} {crust} custom pizza"); System.Console.WriteLine(); break; case 5: if (cart.pizzanum == 0) { System.Console.WriteLine("No pizzas are in your cart."); System.Console.WriteLine(); } else { DisplayCart(cart); } break; case 6: int OrderNum = cart.Pizzas.Count; if (OrderNum > 0) { System.Console.WriteLine("select a pizza to remove"); System.Console.WriteLine("press enter to cancel"); DisplayCart(cart); int delete; int.TryParse(Console.ReadLine(), out delete); if (delete <= OrderNum && delete > 0) { cart.RemovePizza(delete); System.Console.WriteLine("Pizza removed"); System.Console.WriteLine(); } else { System.Console.WriteLine("deletion canceled"); } } else { System.Console.WriteLine("no pizza to delete"); } break; case 7: OrderNum = cart.Pizzas.Count; if (OrderNum > 0) { var fm = new FileManager(); fm.Write(cart); System.Console.WriteLine("Order successfully placed."); } else { System.Console.WriteLine("No pizzas in your cart. Order cannot be placed."); }; //System.Console.WriteLine("Thank you goodbye"); break; case 8: var fmr = new FileManager(); DisplayCart(fmr.Read()); //exit = true; break; case 9: exit = true; break; } } while (!exit); }
//MainMenu handles user input, adding to cart, and displaying user options and selections static void MainMenu(Order cart) { bool exit = false; //int numPizza = 0; do { //display menu options Startup.PrintMenu(); int select; int.TryParse(Console.ReadLine(), out select); //perform action dependent updon what option is selected switch (select) { case 1: SelectOption("Cheese", cart, "L", "Stuffed", new List <string> { "Cheese" }); break; case 2: SelectOption("Pepperoni", cart, "L", "Stuffed", new List <string> { "Pepperoni" }); break; case 3: SelectOption("Hawaiian", cart, "L", "Stuffed", new List <string> { "Pineapples", "Ham" }); break; case 4: SelectOption("Custom", cart, "L", "Stuffed", new List <string> { "It's a Mystery", "Might be History" }); break; case 5: DisplayCart(cart); break; case 6: var fmw = new FileManager(); fmw.Write(cart); System.Console.WriteLine("Thank you, Goodbye"); exit = true; break; case 7: var fmr = new FileManager(); cart = fmr.Read(); break; } System.Console.WriteLine(); } while (!exit); }//end MainMenu