public void AddMoney() { Console.WriteLine(); Console.WriteLine("Your current account balance is $" + catering.AccountBalance); Console.WriteLine("Using only whole dollar amounts and not exceeding $5000 for your account balance, how much would you like to add?"); decimal addMoney = decimal.Parse(Console.ReadLine()); Console.WriteLine(catering.AddMoney(addMoney)); Console.WriteLine(); }
private void AddMoney() { Console.WriteLine("Amount of money to add"); string userinput = Console.ReadLine(); string result = catering.AddMoney(userinput); if (result == "") { Console.WriteLine("Money added."); Console.WriteLine(); } else { Console.WriteLine(result); Console.WriteLine(); } return; }
//main interface public void RunInterface() { //read our caterng menu in file.FileReader(catering); //while loop condition bool done = false; //do a loop while (!done) { //Display main menu ShowMainMenu(); //get our menu option string menuSelection = Console.ReadLine().ToString(); //do a switch with menuSelection switch (menuSelection) { case "1": //log out the full list/menu of catering items RetrievePrintList(); break; case "2": //set up a few conditions bool transactionComplete = false; string purchasingSelection = ""; //go into loop while (!transactionComplete) { //display purchasing menu ShowPurchasingMenu(); //take in user choice input purchasingSelection = Console.ReadLine().ToString(); switch (purchasingSelection) { //Add that moola(money) case "1": //prompt user for money to add Console.WriteLine("How much money would you like to add?"); //set up variable for money decimal wantToAdd = decimal.Parse(Console.ReadLine()); //add the money throught the AddMoney method bool isMoneyValid = catering.AddMoney(wantToAdd); if (isMoneyValid) { // add a log to log.txt with the money and balance generateAddMoneyString(wantToAdd); } else { Console.WriteLine("Account Balance cannot exceed $5000"); } break; //select items for purchase case "2": //prompt for code Console.WriteLine("Enter the code of the item you would like to purchase"); //take in code string itemCode = Console.ReadLine(); //is the code valid? bool validCode = catering.isCodeValid(itemCode); //if invalid, let user know and return to menu if (validCode == false) { Console.WriteLine("Invalid Code, returning to Menu."); break; } //check if the item is sold out bool IsItemSoldOut = catering.IsSoldOut(itemCode); //check if the item is sold out if (IsItemSoldOut) { Console.WriteLine("This item is Sold Out. Returning to Menu."); break; } //prompt for quantity to purchase Console.WriteLine("Please enter the quantity you would like to purchase"); //store quantity in qtyToPurchase int qtyToPurchase = int.Parse(Console.ReadLine()); //check if there is enough stock bool isInventoryEnough = catering.isQuantityEnough(itemCode, qtyToPurchase); //check if there is enough money bool AreWeAbleToPurchase = catering.EnoughMoney(qtyToPurchase, itemCode); //check if there is enough stock if (isInventoryEnough == false) { Console.WriteLine("Not enough stock, please reduce quantity. Returning to Menu."); break; } //check if there is enough money if (AreWeAbleToPurchase == false) { Console.WriteLine("Not enough Money, please reduce quantity. Returning to Menu."); break; } // if all conditions are good, then the next line grabs the item object CateringItem itemPurchased = catering.purchaseItems(itemCode, qtyToPurchase); //now we make a new object to represent the purchased item PurchasedItems pItems = new PurchasedItems(qtyToPurchase, itemPurchased.Price, itemPurchased.Name, itemCode, itemPurchased.Type); //generate string for log.txt generatePurchaseString(pItems); //add our items to our purchase list purchaseList.addToList(pItems); break; //finish transaction, exit loop and return to main menu case "3": //loop through all items in purchaseList and add totalprice up, then log out to customer getCompleteTransaction(); //give customer their change Console.WriteLine(catering.ReturnChange()); //log out to log.txt generateGiveChangeString(); //transactionComplete == true exits the loop and returns to the main menu transactionComplete = true; break; default: break; } } break; //exit the loop case "3": Console.WriteLine("Thank You For Using Our Service. Goodbye."); done = !done; break; default: Console.WriteLine("hi"); break; } } }
//---------- RunInterface METHOD --------------------------------------------------------------------------------------------------------------------------------------------- public void RunInterface() { string userInput = ""; bool isFinished = false; while (!isFinished) { MainMenu(); userInput = Console.ReadLine(); switch (userInput) { case "1": // Case 1.1 - Display Items DisplayItemCategories(); DisplayItems(items); break; case "2": // Case 1.2 - Go to order menu bool isDone = false; while (!isDone) { PurchaseMenu(); Console.WriteLine(); userInput = Console.ReadLine(); switch (userInput) { case "1": // Case 2.1 - Add Money to Balance Console.WriteLine("Please enter deposit amount (must be an integer)"); userInput = Console.ReadLine(); string addMoneyMessage = items.AddMoney(userInput); Console.WriteLine(addMoneyMessage); break; case "2": // Case 2.2 - Select Items Console.WriteLine(); //blank line Console.WriteLine("Please enter valid product code"); string checkProduct = Console.ReadLine(); Console.WriteLine(); //blank line Console.WriteLine("Please enter desired quantity"); string strQuantityDesired = Console.ReadLine(); int intQuantityDesired = int.Parse(strQuantityDesired); string checkProductMessage = items.PurchaseIndividualItem(checkProduct, intQuantityDesired); Console.WriteLine(checkProductMessage); CateringItem selectedItem = null; foreach (CateringItem item in items.ItemList) { if (item.Code == checkProduct) { selectedItem = item; //allows us to get selected item and pass in below break; } } if (checkProductMessage == "ITEM ADDED TO CART") { items.UpdateBalance(selectedItem, intQuantityDesired); } break; case "3": // Case 2.3 - Complete Transaction TenderChange(); Console.WriteLine("List of purchased items and total cost this transaction:"); Console.WriteLine(); DisplayPurchasesCategories(); string printList = items.PrintPurchases(items.PurchasedItems); Console.WriteLine(printList); Console.WriteLine(); //blank line Console.WriteLine("Total: " + items.TotalCost); Console.WriteLine(); //blank line string checkOut = items.BalanceToZero(); Console.WriteLine(checkOut); Console.WriteLine("Press enter to return to main menu"); Console.ReadLine(); isDone = true; //ends the while loop break; default: Console.WriteLine("Please make a valid selection"); break; } Console.WriteLine(); //blank line } break; case "3": isFinished = true; Console.WriteLine("Press Enter To Exit, Enjoy Your Tasty Tasty Food"); break; default: Console.WriteLine("Please make a valid selection"); break; } Console.WriteLine(); //blank line } }