/// <summary> /// Runs the main menu /// </summary> /// <param name="vendingMachine"></param> public override void Run(VendingMachine vendingMachine) { while (true) { Console.Clear(); Console.WriteLine("Welcome to the Vendo-Matic 500"); Console.WriteLine("Please make a choice"); Console.WriteLine("1. Display Vending Machine Items"); Console.WriteLine("2. Purchase"); Console.WriteLine("3. Quit"); string choice = GetString("Pick One: "); if (choice == "1") { vendingMachine.DisplayVendingMachineItems(vendingMachine.inventory); Console.ReadLine(); } else if (choice == "2") { PurchaseMenuCLI purchaseMenu = new PurchaseMenuCLI(); purchaseMenu.Run(vendingMachine); } else if (choice == "Q" || choice == "q" || choice == "3") { break; } else { Console.WriteLine("Invalid Option."); Console.ReadLine(); } } }
public override void Run() { string error = string.Empty; while (true) { Console.Write("Errors: "); Console.WriteLine(error); Console.WriteLine("Welcome To The Vendo-Matic 500! "); Console.WriteLine("Please select an option: "); Console.WriteLine("1) Display Inventory"); Console.WriteLine("2) Purchase"); Console.WriteLine("Q) Quit"); Console.WriteLine(); string mainChoice = this.GetString("> Selection: ").ToLower(); if (mainChoice == "1") { this.DisplayInv(); error = string.Empty; Console.ReadLine(); } else if (mainChoice == "2") { PurchaseMenuCLI purchaseMenu = new PurchaseMenuCLI(vm); purchaseMenu.Run(); error = string.Empty; } else if (mainChoice == "q") { break; } else { error = "Invalid option."; } Console.Clear(); } }