public void Display() { while (true) { //Console.Clear(); Console.WriteLine("Main Menu"); Console.WriteLine(); Console.WriteLine("<1> View Inventory"); //VIEW INVENTORY Console.WriteLine("<2> Purchase Menu."); //PURCHASE MENU Console.WriteLine("<Q> Finish Transaction/Quit"); //FINISH TRANSACTION & QUIT Console.WriteLine(); Console.Write(">"); string userInput = Console.ReadLine(); if (userInput == "1") { Console.Clear(); InventoryMenu inventoryMenu = new InventoryMenu(MainMenu.vm); inventoryMenu.Display(); } else if (userInput == "2") { Console.Clear(); PurchaseMenu submenu = new PurchaseMenu(vm); submenu.Display(); } else if (userInput.ToUpper() == "Q") { vm.FW.GenerateSalesReport(vm.TransactionLog); Console.BackgroundColor = ConsoleColor.DarkMagenta; Console.Clear(); Console.WriteLine(); Console.WriteLine("Change Due: $" + vm.Balance); PrintChangeDue(); PrintPurchasedItems(); ResizeAndExitWindow(); return; } else { Console.WriteLine("INVALID INPUT"); } } }
public void Display() { while (true) { Console.WriteLine(); Console.WriteLine("Purchase Menu"); Console.WriteLine("What would you like to do?"); Console.WriteLine("<1> Insert Money"); //ADD MONEY TO BALANCE Console.WriteLine("<2> Buy Item"); //CHOSE ITEM Console.WriteLine("<3> View Inventory Menu"); //VIEW INVENTORY MENU Console.WriteLine("<4> Quit to Main Menu"); //QUIT TO MAIN MENU Console.WriteLine($"Total Amount Inserted: {vm.Balance.ToString("C2")}"); Console.WriteLine(); Console.Write(">"); string userInput = Console.ReadLine(); if (userInput == "1") { Console.Clear(); Console.WriteLine("Current Balance: $" + vm.Balance); Console.Write("Please insert money: $ "); int input = GetInteger(Console.ReadLine()); vm.AcceptCash(input); Console.Clear(); } else if (userInput == "2") { Console.Clear(); Console.WriteLine("Current Balance: $" + vm.Balance); Console.Write(">Enter Slot Code: "); string userSelection = Console.ReadLine().ToUpper(); if (!vm.Inventory.ContainsKey(userSelection)) { Console.WriteLine("Invalid Slot Code. Please Try Again."); } else if (vm.Inventory[userSelection].Count == 0) { Console.Beep(1955, 45); Console.Beep(1955, 50); Console.WriteLine("Sold out. Womp womp womp."); } else if (vm.Inventory[userSelection][0].Price > vm.Balance) { Console.Beep(1955, 65); Console.Beep(1955, 50); Console.WriteLine("Insufficient funds. Womp womp womp."); } else { vm.BuyItem(userSelection); Console.Clear(); Console.WriteLine("VENDING...."); Console.WriteLine(); System.Threading.Thread.Sleep(400); Console.WriteLine("Item Dispensed."); Console.WriteLine(); } } else if (userInput == "3") { Console.Clear(); InventoryMenu inventoryMenu = new InventoryMenu(MainMenu.vm); inventoryMenu.Display(); } else if (userInput == "4") { Console.Clear(); return; //MainMenu mainMenu = new MainMenu(vm); //mainMenu.Display(); //<-- breaks off the whileloop and because it's the end of the line for the entire method so it pops off the stack and returns to the main menu } else { Console.WriteLine("Invalid Input. Try Again"); } } }