/// <summary> /// The override of ExecuteSelection handles whatever selection was made by the user. /// This is where any business logic is executed. /// </summary> /// <param name="choice">"Key" of the user's menu selection</param> /// <returns></returns> protected override bool ExecuteSelection(string choice) { switch (choice) { case "1": foreach (VendingItem item in MyVendingMachine.Inventory) { if (item.AmountInStock == 0) { Console.WriteLine($"{item.SlotLocation,-4} {item.Name,-20} {item.Price,3:C} \tQuantity: OUT OF STOCK"); } else { Console.WriteLine($"{item.SlotLocation,-4} {item.Name, -20} {item.Price, 3:C} \tQuantity: {item.AmountInStock}"); } } Pause(""); return(true); case "2": PurchaseMenu menu = new PurchaseMenu(MyVendingMachine, MyMoneyManager); menu.Run(); return(true); } return(true); }
/// <summary> /// The override of ExecuteSelection handles whatever selection was made by the user. /// This is where any business logic is executed. /// </summary> /// <param name="choice">"Key" of the user's menu selection</param> /// <returns></returns> protected override bool ExecuteSelection(string choice) { switch (choice) { case "1": PurchaseMenu newPurchaseMenu = new PurchaseMenu(Vendo_Matic_800); newPurchaseMenu.Run(); return(true); case "M": MainMenu mainMenu = new MainMenu(Vendo_Matic_800); mainMenu.Run(); return(true); } return(true); }
/// <summary> /// The override of ExecuteSelection handles whatever selection was made by the user. /// This is where any business logic is executed. /// </summary> /// <param name="choice">"Key" of the user's menu selection</param> /// <returns>True if we want to stay in the menu loop, false otherwise</returns> protected override bool ExecuteSelection(string choice) { switch (choice) { case "1": // Print out the stock of our vending machine VendOMatic.ShowContents(); Console.ReadKey(); return(true); case "2": // The purchase sub menu { PurchaseMenu purchaseMenu = new PurchaseMenu(); purchaseMenu.Receive(VendOMatic, this.Customer); purchaseMenu.Run(); } return(true); } return(true); }
/// <summary> /// The override of ExecuteSelection handles whatever selection was made by the user. /// This is where any business logic is executed. /// </summary> /// <param name="choice">"Key" of the user's menu selection</param> /// <returns></returns> protected override bool ExecuteSelection(string choice) { switch (choice) { case "1": Console.Clear(); Vendomatic.DisplayVendingMachineItems(); Pause(""); return(true); case "2": PurchaseMenu Menu = new PurchaseMenu(Vendomatic); Menu.Run(); Pause(""); return(true); } return(true); }
//public VendingMachine Vendo_Matic_800 { get; set; } /// <summary> /// The override of ExecuteSelection handles whatever selection was made by the user. /// This is where any business logic is executed. /// </summary> /// <param name="choice">"Key" of the user's menu selection</param> /// <returns></returns> protected override bool ExecuteSelection(string choice) { switch (choice) { case "1": ItemsMenu itemsMenu = new ItemsMenu(Vendo_Matic_800); itemsMenu.Run(); return(true); case "2": PurchaseMenu purchaseMenu = new PurchaseMenu(Vendo_Matic_800); purchaseMenu.Run(); return(true); case "E": Console.Clear(); Console.WriteLine($"***** Thank you for using the Vendo-Matic-800!!! *****"); Console.WriteLine(); Vendo_Matic_800.quarters = 0; Vendo_Matic_800.dimes = 0; Vendo_Matic_800.nickels = 0; Vendo_Matic_800.EndVending(); string changeString = $"Please take your change: {Vendo_Matic_800.quarters} Quarters, {Vendo_Matic_800.dimes} Dimes, {Vendo_Matic_800.nickels} Nickels."; Console.WriteLine(new string('=', changeString.Length)); Console.WriteLine(changeString); Console.WriteLine(new string('=', changeString.Length)); Console.WriteLine(); Console.WriteLine("Press [ENTER] to continue!"); Console.ReadLine(); Environment.Exit(0); return(false); case "4": Vendo_Matic_800.GenerateSalesReport(); return(true); } return(true); }
/// <summary> /// The override of ExecuteSelection handles whatever selection was made by the user. /// This is where any business logic is executed. /// </summary> /// <param name="choice">"Key" of the user's menu selection</param> /// <returns></returns> protected override bool ExecuteSelection(string choice) { switch (choice) { case "1": // Display output of file containing Position # and Item List <string> listToDisplay = new List <string>(); listToDisplay = MyMachine.GiveMenuProductList(); foreach (string word in listToDisplay) { Console.WriteLine(word); } Pause(""); return(true); case "2": // Sends user to the purchase menu PurchaseMenu menu = new PurchaseMenu(this.MyMachine); menu.Run(); return(true); } return(true); }
/// <summary> /// The override of ExecuteSelection handles whatever selection was made by the user. /// This is where any business logic is executed. /// </summary> /// <param name="choice">"Key" of the user's menu selection</param> /// <returns></returns> protected override bool ExecuteSelection(string choice) { switch (choice) { case "1": foreach (KeyValuePair <string, Product> kvp in base.VM.products) { Console.WriteLine($"{kvp.Value.Code.PadRight(10)}{kvp.Value.Name.PadRight(15)}{kvp.Value.Cost.ToString().PadRight(10)}{kvp.Value.ProductType.PadRight(10)}{kvp.Value.NumberItemsRemaining}"); } Pause(""); return(true); case "2": // Get some input form the user, and then do something PurchaseMenu pm = new PurchaseMenu(base.VM); pm.Run(); Pause(""); return(true); case "3": return(false); } return(true); }
// ..\etc\VendingMachineAuditLog /// <summary> /// The override of ExecuteSelection handles whatever selection was made by the user. /// This is where any business logic is executed. /// </summary> /// <param name="choice">"Key" of the user's menu selection</param> /// <returns></returns> protected override bool ExecuteSelection(string choice) { switch (choice) { // Create the display menu case "1": foreach (ProductIdentification product in VendoMatic.PublicVendingMachine) { Console.WriteLine($"{product.LocationID} | {product.Name} | {product.Price} | {product.Category}"); } Console.ReadLine(); return(true); // Create the purchase menu case "2": PurchaseMenu purchaseMenu = new PurchaseMenu(VendoMatic); purchaseMenu.Run(); return(true); } return(true); }
protected decimal GetDecimal(string message) { decimal resultValue = 0; while (true) { Console.Write(message + " "); string userInput = Console.ReadLine().Trim(); if (decimal.TryParse(userInput, out resultValue)) { break; } if (userInput == "") { PurchaseMenu purchaseMenu = new PurchaseMenu(Vendo_Matic_800); purchaseMenu.Run(); } else { Console.WriteLine("!!! Invalid input !!! "); } } return(resultValue); }
/// <summary> /// Accepts user intput, makes it readable regardless of case, then decides the next course of action based on the user's choice. /// </summary> /// <param name="message"></param> /// <returns></returns> protected override string GetString(string message) { while (true) { Console.Write(message + " "); string userInput = Console.ReadLine().Trim().ToUpper(); if (!String.IsNullOrEmpty(userInput)) { foreach (Slots slot in Vendo_Matic_800.slotList) { string itemID = slot.SlotID; int itemAmountAvailable = slot.Amount; string itemName = Vendo_Matic_800.vendingStock[itemID].Name; decimal itemPrice = Vendo_Matic_800.vendingStock[itemID].Price; if (userInput == itemID && Vendo_Matic_800.Balance >= itemPrice) { if (slot.Amount >= 1) { Console.Clear(); string dispenseString = $"Dispensing: {Vendo_Matic_800.vendingStock[slot.SlotID].Name} | {Vendo_Matic_800.vendingStock[slot.SlotID].Price:C} has been deducted from your balance."; Console.WriteLine(new string('=', dispenseString.Length)); Vendo_Matic_800.Spend(itemPrice); Vendo_Matic_800.Dispense(slot); Console.WriteLine(dispenseString); Console.WriteLine(); Console.WriteLine($"{Vendo_Matic_800.vendingStock[slot.SlotID].Message}"); Console.WriteLine(); Console.WriteLine($"Your new Balance is: {Vendo_Matic_800.Balance:C}"); Console.WriteLine(new string('=', dispenseString.Length)); } if (itemAmountAvailable < 1) { Console.Clear(); string soldOutString = $"!!!!!!!!!!!!!!!!!! SOLD OUT !!!!!!!!!!!!!!!!!!"; Console.WriteLine(new string('=', soldOutString.Length)); Console.WriteLine(soldOutString); Console.WriteLine(new string('=', soldOutString.Length)); Vendo_Matic_800.Deposit(itemPrice); Pause("Please make another selection,"); break; } Pause("Thank you for your purchase,"); PurchaseMenu purchaseMenu = new PurchaseMenu(Vendo_Matic_800); purchaseMenu.Run(); } else if (userInput == itemID) { Console.Clear(); Vendo_Matic_800.Spend(itemPrice); Pause("Tough Luck!,"); PurchaseMenu purchaseMenu = new PurchaseMenu(Vendo_Matic_800); purchaseMenu.Run(); } } return(userInput); } else { return("!!! Invalid input. Please enter a valid decimal number."); } } }