Exemple #1
0
        public static void CreditCard(List <FoodItem> order)
        {
            decimal orderTotal = OrderOptions.GetTotalCost(order, OrderOptions.taxPercentageDecimal);

            Console.WriteLine($"You are paying {String.Format("{0:C}", orderTotal)} by credit card. Please enter your credit card number:");
            string ccNum = Validation.CreditCardVal(Console.ReadLine());

            int secCode;

            if (ccNum[0] == 3)
            {
                Console.WriteLine("Please enter the 4 digit security code on the front of your card.");
                secCode = Validation.SecurityCodeVal(Console.ReadLine(), 4);
            }
            else
            {
                Console.WriteLine("Please enter the 3 digit security code on the back of your card.");
                secCode = Validation.SecurityCodeVal(Console.ReadLine(), 3);
            }

            Console.WriteLine("Please enter the expiration date in format MM/YYYY:");
            string ccExp = Validation.DateVal(Console.ReadLine());

            Console.WriteLine("Thank you!");
            OrderOptions.ListCurrentOrderDetails(order, " Receipt  ");

            Console.WriteLine($"{String.Format("{0:C}", orderTotal)} has been paid via your credit card: \n");
            Console.WriteLine($"{"Card Number:",20}{ccNum,25}");
            Console.WriteLine($"{"Security Code:",20}{secCode,25}");
            Console.WriteLine($"{"Expiration Date:",20}{ccExp,25}\n");
            Console.WriteLine("Have a great day!\n");
        }
Exemple #2
0
        public static void Check(List <FoodItem> order)
        {
            decimal orderTotal = OrderOptions.GetTotalCost(order, OrderOptions.taxPercentageDecimal);

            Console.WriteLine($"You are paying {String.Format("{0:C}", orderTotal)} by check. Please enter your 9 digit bank routing number:");
            double routingNum = Validation.CheckNumsVal(Console.ReadLine(), 12);

            Console.WriteLine("\nPlease enter your bank account number:");
            double acctNum = Validation.CheckNumsVal(Console.ReadLine(), 12);

            Console.WriteLine("\nPlease enter the check number:");
            double checkNum = Validation.CheckNumsVal(Console.ReadLine(), 20);

            OrderOptions.ListCurrentOrderDetails(order, " Receipt  ");

            Console.WriteLine($"{String.Format("{0:C}", orderTotal)} has been paid via check: \n");
            Console.WriteLine($"{"Check Details:",14}{$" {routingNum} {acctNum} {checkNum}",31}");
            Console.WriteLine("\nHave a great day!\n");
        }
Exemple #3
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");
                }
            }
        }
        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!");
            }
        }
        public static void OrderMenu(Dictionary <string, FoodItem> foodDictionary)
        {
            List <FoodItem> userOrder = new List <FoodItem>();

            bool killswitch = true;

            while (killswitch)
            {
                //Console.WriteLine("\nWhat would you like to do?\n" +
                //    "1. Add an item to your order\n" +
                //    "2. View Your Order\n" +
                //    "3. View the Menu\n" +
                //    "4. Check Out\n" +
                //    "5. Cancel order and go back to main menu.\n");
                Console.Clear();
                Console.WriteLine(@"
......................................................................
|,---. .          ,-. .       .       ,--.    ,-. .                  |
|  |   |         /    |       |       |      /    |                  |
|  |   |-. ,-.   |    |-. ,-: |-  --- |-     |    |-. ,-. ,-. ,-. ,-.|
|  |   | | |-'   \    | | | | |       |      \    | | |-' |-' `-. |-'|
|  '   ' ' `-'    `-' ' ' `-` `-'     `--'    `-' ' ' `-' `-' `-' `-'|                                                                     
|....................................................................|
| : : : :::#:#:#:#:##:##:######:#####:#############|________|________|
| : : : :::#:#:#:#:##:##:######:#####:#############|        |        |
| : : : : : ::#:#:#:#:#:##:###:###:#####:##########|        |        |
| : : :  (-) :::#:#:#:#:#:#:##:####:###:###:####:##|        |        |
|______.-'-'-.___________________________:####::###|________|________|
|      |-...-|   _______   .--''''''--.  \:###:#####:################|
|      |;:.._|  / MENU /  |'''''/      |  \:#                     ###|
|      `-...-' / ==== /   '''''/_...--'|   \#   1. Add food       ###|
|             /______/     /\  |__...--'    \   2. View order     ###|
|_________________________/  \_______________\  3. Look at menu      |
|                                      | |      4. Check out         |
|  So you want to order some food, eh? | |      5. Never mind. Go    |
|  Hit me.                             | |         back.             |
|......................................|.|...........................|
");
                Console.Write("Type a number to make a selection: ");

                string userOrderMenuInput = Console.ReadLine();
                switch (userOrderMenuInput)
                {
                case "1":
                    Console.Clear();
                    OrderOptions.ListFoodMenu(foodDictionary);
                    userOrder = OrderOptions.AddFoodItem(userOrder, foodDictionary);
                    Console.WriteLine("\nPress enter to continue.\n");
                    string x = Console.ReadLine();
                    break;

                case "2":
                    Console.Clear();
                    OrderOptions.ListCurrentOrderDetails(userOrder, "Your Order");
                    Console.WriteLine("\nPress enter to continue.\n");
                    string y = Console.ReadLine();
                    break;

                case "3":
                    Console.Clear();
                    OrderOptions.ListFoodMenu(foodDictionary);
                    Console.WriteLine("\nPress enter to continue.\n");
                    string z = Console.ReadLine();
                    break;

                case "4":
                    Console.Clear();
                    killswitch = MenusClass.CheckoutMenu(userOrder);
                    break;

                case "5":
                    Console.WriteLine("Are you sure you want to cancel this transaction? Y/N");
                    string uSure = Console.ReadLine();
                    if (uSure.ToUpper() == "Y")
                    {
                        killswitch = false;
                    }
                    break;
                }
            }
        }
        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;
                }
            }
        }