Example #1
0
        public static void Cash(List <FoodItem> order)
        {
            //List Receipt

            decimal orderTotal    = OrderOptions.GetTotalCost(order, OrderOptions.taxPercentageDecimal);
            decimal moneyTendered = 0;

            while (moneyTendered < orderTotal)
            {
                Console.WriteLine("\nHow much cash are you paying?");

                moneyTendered = moneyTendered + (Convert.ToDecimal(Validation.NumberVal(Console.ReadLine())));

                if (moneyTendered > orderTotal)
                {
                    Console.WriteLine($"Thank you! You've paid {String.Format("{0:C}", moneyTendered)}.\n" +
                                      $"Your change is {String.Format("{0:C}", moneyTendered - orderTotal)}\n" +
                                      $"Have a great day!\n");
                }

                else if (moneyTendered == orderTotal)
                {
                    Console.WriteLine($"Thank you! You've paid {String.Format("{0:C}", moneyTendered)}.\n" +
                                      $"Have a great day!\n");
                }

                else
                {
                    Console.WriteLine($"Thank you! You've paid {String.Format("{0:C}", moneyTendered)}.\n" +
                                      $"You still have {String.Format("{0:C}", orderTotal - moneyTendered)} left on this order.");
                }

                if (moneyTendered >= orderTotal)
                {
                    OrderOptions.ListCurrentOrderDetails(order, " Receipt  ");
                    Console.WriteLine($"\n{"Money Tendered:",39}{String.Format("{0:C}", moneyTendered),6}\n");
                    Console.WriteLine($"{"Change:",39}{String.Format("{0:C}", moneyTendered - orderTotal),6}\n");
                }
            }
        }
Example #2
0
        public static List <FoodItem> AddFoodItem(List <FoodItem> order, Dictionary <string, FoodItem> foodDictionary)
        {
            while (true)
            {
                Dictionary <int, string> chooseFromDict = new Dictionary <int, string>();
                int i = 0;
                foreach (KeyValuePair <string, FoodItem> pair in foodDictionary)
                {
                    FoodItem item = pair.Value;
                    chooseFromDict.Add(i, item.Name);
                    i++;
                }

                Console.WriteLine("\nYou can type in either the number or the full name of the item.\n" +
                                  "You can also type \"cancel\" to go back to the main order menu or \"menu\" to view the menu again.\n");
                Console.Write("What would you like to add to your order:");
                string userChooseInput = Console.ReadLine();
                if (userChooseInput.ToLower() == "menu")
                {
                    OrderOptions.ListFoodMenu(foodDictionary);
                    continue;
                }
                if (userChooseInput.ToLower() == "cancel")
                {
                    return(order);
                }
                string userChoice;
                int    userNumberInput;
                if (Int32.TryParse(userChooseInput, out userNumberInput) && userNumberInput <= foodDictionary.Count())
                {
                    userChoice = chooseFromDict[userNumberInput - 1];
                }

                else if (Int32.TryParse(userChooseInput, out userNumberInput) && userNumberInput >= foodDictionary.Count())
                {
                    userChoice = "";
                }

                else
                {
                    userChoice = userChooseInput;
                }
                // have userChoice, which is a string that contains the name of the thing in theory

                foreach (KeyValuePair <string, FoodItem> pair in foodDictionary)
                {
                    FoodItem item = pair.Value;
                    if (item.Name.ToLower() == userChoice.ToLower())
                    {
                        Art.Display(item.Name.ToLower());
                        Console.WriteLine($"How many {item.Name}s do you want to add?");
                        int numberOfItem = Convert.ToInt32(Validation.NumberVal(Console.ReadLine()));
                        if (numberOfItem == 0)
                        {
                            Console.WriteLine("Nothing was added.");
                            return(order);
                        }
                        else
                        {
                            int integer = 0;
                            for (integer = 0; integer < numberOfItem; integer++)
                            {
                                order.Add(item);
                            }

                            if (integer == 1)
                            {
                                Console.WriteLine($"{integer} {item.Name} has been added to your order!");
                            }
                            else
                            {
                                Console.WriteLine($"{integer} {item.Name}s have been added to your order!");
                            }
                            return(order);
                        }
                    }
                }

                Console.WriteLine("Sorry, couldn't find that item. Try again!");
            }
        }
Example #3
0
        public static bool CheckoutMenu(List <FoodItem> order)
        {
            while (true)
            {
                //Console.WriteLine($"Now checking you out. Your total is {String.Format("{0:C}", OrderOptions.GetTotalCost(order, OrderOptions.taxPercentageDecimal))}\n" +
                //    "Type in a number from the list to:\n" +
                //    "1. Pay by Cash\n" +
                //    "2. Pay by Credit Card\n" +
                //    "3. Pay by Check\n" +
                //    "4. Cancel and go back to your order\n");
                //OrderOptions.ListCurrentOrderDetails(order, "Your Order");
                Console.WriteLine(@"
......................................................................
|,---. .          ,-. .       .       ,--.    ,-. .                  |
|  |   |         /    |       |       |      /    |                  |
|  |   |-. ,-.   |    |-. ,-: |-  --- |-     |    |-. ,-. ,-. ,-. ,-.|
|  |   | | |-'   \    | | | | |       |      \    | | |-' |-' `-. |-'|
|  '   ' ' `-'    `-' ' ' `-` `-'     `--'    `-' ' ' `-' `-' `-' `-'|                                                                     
|....................................................................|
| : : : :::#:#:#:#:##:##:######:#####:#############|________|________|
| : : : :::#:#:#:#:##:##:######:#####:#############|        |        |
| : : : : : ::#:#:#:#:#:##:###:###:#####:##########|        |        |
| : : :  (-) :::#:#:#:#:#:#:##:####:###:###:####:##|        |        |
|______.-'-'-.___________________________:####::###|________|________|
|      |-...-|    _____    .--''''''--.  \:###:#####:################|
|      |;:.._| O/ BILL /  |'''''/      |  \:#                     ###|
|      `-...-' /oO  o /   '''''/_...--'|   \#   1. Pay with Cash  ###|
|            o/O____O/     /\  |__...--'    \   2. Pay with Check ###|
|_________________________/  \_______________\  3. Pay with Credit   |
|                                      | |         card.             |");
                Console.WriteLine($"| Your total is { $"{String.Format("{0:C}", OrderOptions.GetTotalCost(order, OrderOptions.taxPercentageDecimal))}",-10}             | |      4. Never mind. Go    | ");
                Console.WriteLine("| How are you paying?                  | |         back.             |\n" +
                                  "|......................................|.|...........................| \n");

                Console.Write("Type a number to make a selection: ");

                int checkoutUserInput = Convert.ToInt32(Validation.NumberVal(Console.ReadLine()));
                switch (checkoutUserInput)
                {
                case 1:
                    Console.Clear();
                    OrderOptions.ListCurrentOrderDetails(order, "Your Order");

                    Checkout.Cash(order);
                    Console.WriteLine("\nPress enter to continue.\n");
                    string z = Console.ReadLine();
                    return(false);

                case 2:
                    Console.Clear();
                    OrderOptions.ListCurrentOrderDetails(order, "Your Order");
                    Checkout.Check(order);
                    Console.WriteLine("\nPress enter to continue.\n");
                    string y = Console.ReadLine(); return(false);

                case 3:
                    Console.Clear();
                    OrderOptions.ListCurrentOrderDetails(order, "Your Order");

                    Checkout.CreditCard(order);
                    Console.WriteLine("\nPress enter to continue.\n");
                    string x = Console.ReadLine();
                    return(false);

                case 4:
                    Console.Clear();
                    return(true);

                default:
                    Console.WriteLine("Not an option. Please try again..");
                    break;
                }
            }
        }