static void Main(string[] args) { bool menuFile = false; bool pizzaFile = false; bool burgerFile = false; bool extraFile = false; Order o = new Order(); while (true) { int intVal; string menuSelection = ds.DisplayMenu(menuFile); menuFile = true; bool isMsValid = int.TryParse(menuSelection, out intVal); if (isMsValid && intVal < ds.fullMenuList.Count && intVal >= 0) { if (menuSelection == "0") { break; } if (menuSelection == ds.fullMenuList[0][0]) { Pizza p = new Pizza(); while (true) { int pVal; string pToppingSelection = ds.DisplayPizzaToppings(pizzaFile); pizzaFile = true; bool isPtValid = int.TryParse(pToppingSelection, out pVal); if (isPtValid && pVal <= ds.pizzaToppingList.Count && pVal >= 0) { if (pVal == 0) { o.AddToOrder(p); break; } p.AddTopping(ds.pizzaToppingList[pVal - 1][1], decimal.Parse(ds.pizzaToppingList[pVal - 1][2])); foreach (var pt in p.MyPizzaToppings) { Console.WriteLine($"{pt.name} {pt.price:C}"); } } else { ds.InvalidInput(); } } } if (menuSelection == ds.fullMenuList[1][0]) { Burger b = new Burger(); while (true) { int bVal; string bToppingSelection = ds.DisplayBurgerToppings(burgerFile); burgerFile = true; bool isBtValid = int.TryParse(bToppingSelection, out bVal); if (isBtValid && bVal <= ds.burgerToppingList.Count && bVal >= 0) { if (bVal == 0) { o.AddToOrder(b); break; } b.AddTopping(ds.burgerToppingList[bVal - 1][1], decimal.Parse(ds.burgerToppingList[bVal - 1][2])); foreach (var bt in b.MyBurgerToppings) { Console.WriteLine($"{bt.name} {bt.price:C}"); } } else { ds.InvalidInput(); } } } if (menuSelection == ds.fullMenuList[2][0]) { while (true) { int eVal; Extra e = new Extra(); string eSelection = ds.DisplayExtras(extraFile); extraFile = true; bool isExValid = int.TryParse(eSelection, out eVal); if (isExValid && eVal <= ds.extraList.Count && eVal >= 0) { if (eVal == 0) { break; } e.Item = ds.extraList[eVal - 1][1]; e.Size = ds.extraList[eVal - 1][2][0]; e.Price = decimal.Parse(ds.extraList[eVal - 1][3]); o.AddToOrder(e); } else { ds.InvalidInput(); } } } } else { ds.InvalidInput(); } } o.Total(); }
static void Main(string[] args) { Console.Clear(); Order order = new Order(); decimal personMoney = 100m; bool payed = false; int input = 1; while (input != 0) { Console.WriteLine("Choose Menu Option"); MenuItems.CreateMenu(MenuItems.MainMenuItems.mainMenuItemsList); Console.WriteLine("[0] Exit Restaurant"); Console.WriteLine("Your pick: "); while (!int.TryParse(Console.ReadLine(), out input)) { Console.Clear(); Console.WriteLine("Choose Menu Option"); MenuItems.CreateMenu(MenuItems.MainMenuItems.mainMenuItemsList); Console.WriteLine("[0] Exit Restaurant"); Console.WriteLine("You entered an invalid choice"); Console.Write("Pick Again "); } Console.WriteLine(""); switch (input) { case 1: //build burger Burger burger = new Burger(); int choice = 1; order.BuildBurgerOrder(order, choice, burger); break; case 2: //build pizza Pizza pizza = new Pizza(); choice = 1; order.BuildPizzaOrder(order, choice, pizza); break; case 3: //Extra Items Extra extra = new Extra(); int choiceItem = 1; int choiceSize = 1; order.BuildExtraOrder(choiceItem, choiceSize, order, extra); break; case 4: //Checkout Console.WriteLine("\nThank you for eating with us!!\n**** Here is your receipt ****\n"); order.ShowBurgerOrder(); order.ShowPizzaOrder(); order.ShowExtraOrder(); order.CheckOut(personMoney); Console.WriteLine("\nCome again!!\n Press 0 to exit....\n"); Console.ReadLine(); Console.Clear(); order.ClearAllOrdersAndList(); payed = true; break; default: char oops; if (input == 0 && payed == false && (order.MyBurgers.Count + order.MyExtras.Count + order.MyPizzas.Count) > 0) { Console.WriteLine($"\nOops you forgot to pay, did you mean to Checkout and pay instead? Press Y for yes."); while (!char.TryParse(Console.ReadLine(), out oops)) { Console.WriteLine($"\nOops you forgot to pay, did you mean to Checkout and pay instead? Press Y for yes."); } if (oops == 'y' || oops == 'Y') { Console.WriteLine("\nThank you for eating with us!!\n**** Here is your receipt ****\n"); order.ShowBurgerOrder(); order.ShowPizzaOrder(); order.ShowExtraOrder(); order.CheckOut(personMoney); Console.WriteLine("\nCome again!!\n Press 0 to exit....\n"); Console.ReadLine(); Console.Clear(); order.ClearAllOrdersAndList(); payed = true; } else { input = 0; payed = false; Console.WriteLine($"YOU LEFT WITHOUT PAYING " + order.CheckOut(personMoney).ToString("C") + "\nSHAME ON YOU!!!!!"); Console.WriteLine("\n\nPress Enter to Exit Program...."); Console.ReadLine(); //continue; } } else { Console.WriteLine("\n\nPress Enter to Exit Program...."); Console.ReadLine(); } break; } } }
public void AddToOrder(Burger _burger) { myBurgers.Add(_burger); }
public void AddToBurgerOrder(Burger burger) { this.MyBurgers.Add(burger); }