示例#1
0
        public void DisplayOption2()
        {
            bool done = false;

            while (!done)
            {
                Menu2();
                Console.WriteLine("Current Account Balance: $" + accountBalanceSum);
                Console.WriteLine();

                string userOption = Console.ReadLine();


                switch (userOption)
                {
                case "1":
                    Console.WriteLine();
                    Console.WriteLine("Enter amount to add: ");
                    double moneyAdded = double.Parse(Console.ReadLine());
                    accountBalanceSum = catering.AddMoneyToBalance(moneyAdded, accountBalanceSum);
                    Console.WriteLine();

                    newFileAccssed.WriteAuditLog1(moneyAdded, accountBalanceSum);

                    break;

                case "2":
                    Console.WriteLine();
                    accountBalanceSum = Menu2Option2(catering, accountBalanceSum);
                    break;

                case "3":
                    Console.WriteLine();
                    double totalSpent = 0;
                    catering.ReturnChange(accountBalanceSum);
                    Console.WriteLine("Receipt");
                    foreach (CateringItem item in catering.itemsPurchased)
                    {
                        Console.WriteLine($"{item.Amount} {item.Name} ${item.Price} per ${item.TotalPrice} total {item.Type}");
                        totalSpent += double.Parse(item.TotalPrice);
                    }
                    Console.WriteLine("Total Spent: " + "$" + totalSpent);
                    Console.WriteLine();
                    Console.WriteLine("Your change is: " + catering.changeDict["Twenties"] + " Twenties, " +
                                      catering.changeDict["Tens"] + " Tens, " + catering.changeDict["Fives"] + " Fives, " +
                                      catering.changeDict["Ones"] + " Ones and " + catering.changeDict["Quarters"] + " Quarters, " +
                                      catering.changeDict["Dimes"] + " Dimes, " + catering.changeDict["Nickels"] + " Nickels.");

                    newFileAccssed.WriteAuditLog3(accountBalanceSum);

                    accountBalanceSum = 0;
                    catering.itemsPurchased.RemoveRange(0, catering.itemsPurchased.Count);
                    return;
                }
            }
        }