Esempio n. 1
0
        public static void Cash()
        {
Monay:
            try
            {
                Console.Write("Please enter the amount of cash you are using: ");
                string cash = Console.ReadLine();
                if ((Regex.IsMatch(cash, @"(^[0-9]{1,3}\.[0-9]{2}$)")))
                {
                    if (Change(cash) < Compute.Grandtotal(Compute.ShowSubtotal(), Compute.TaxedAmount(Compute.ShowSubtotal())))
                    {
                        Console.WriteLine("Sorry, Please pay in full.");
                        Money();
                    }
                    else if (Change(cash) >= Compute.Grandtotal(Compute.ShowSubtotal(), Compute.TaxedAmount(Compute.ShowSubtotal())))
                    {
                        Console.WriteLine("\n");
                        Console.WriteLine("Five Below Bodega Receipt\n");
                        Console.WriteLine("Subtotal......................" + Compute.ShowSubtotal().ToString("C2"));
                        Console.WriteLine("Tax..........................." + Compute.Taxtotal(Compute.ShowSubtotal()).ToString("C2"));
                        Console.WriteLine("Total........................." + Compute.Grandtotal(Compute.ShowSubtotal(), Compute.TaxedAmount(Compute.ShowSubtotal())).ToString("C2"));
                        Console.WriteLine("Cash......................" + cash);
                        Console.WriteLine("Your Change is............... " + ChangeDue(Change(cash), Compute.Grandtotal(Compute.ShowSubtotal(), Compute.TaxedAmount(Compute.ShowSubtotal()))).ToString("C2") + "\n");
                    }
                }
                if ((!Regex.IsMatch(cash, @"(^[0-9]{1,3}\.[0-9]{2}$)")))
                {
                    Console.WriteLine("Please try again.");
                    //if invalid input shoots back up to Monay:
                    goto Monay;
                }
            }
            catch (ArgumentNullException)
            {
                Console.WriteLine("Cannot input nothing.");
                goto Monay;
            }
            catch (NullReferenceException)
            {
                Console.WriteLine("Cannot input nothing.");
                goto Monay;
            }
            catch (Exception)
            {
                Console.WriteLine("Invalid Input.");
                //goes back to the top asking how much cash theyre paying with
                goto Monay;
            }
        }
Esempio n. 2
0
        public static void Check()
        {
Checkers:
            try
            {
                Console.Write("Please enter the check number: ");
                string cash = Console.ReadLine();
                if ((Regex.IsMatch(cash, @"(^[0-9]{9}$)")))
                {
                    Console.WriteLine("\n");
                    Console.WriteLine("Five Below Bodega Receipt\n");
                    Console.WriteLine("Subtotal......................" + Compute.ShowSubtotal().ToString("C2"));
                    Console.WriteLine("Tax..........................." + Compute.Taxtotal(Compute.ShowSubtotal()).ToString("C2"));
                    Console.WriteLine("Total........................." + Compute.Grandtotal(Compute.ShowSubtotal(), Compute.TaxedAmount(Compute.ShowSubtotal())).ToString("C2"));
                    Console.WriteLine("Check #................" + cash);
                    Console.WriteLine("Paid In Full\n");
                }
                else if ((!Regex.IsMatch(cash, @"(^[0-9]{9}$)")))
                {
                    Console.WriteLine("Please try again.");
                    //if invalid input shoots back up to Chekers:
                    goto Checkers;
                }
            }
            catch (ArgumentNullException)
            {
                Console.WriteLine("Cannot input nothing.");
                goto Checkers;
            }
            catch (NullReferenceException)
            {
                Console.WriteLine("Cannot input nothing.");
                goto Checkers;
            }
            catch (Exception)
            {
                Console.WriteLine("Invalid Input.");
                //goes back to the top asking how to input there check number
                goto Checkers;
            }
        }
Esempio n. 3
0
        public static void StartTerminal()

        {
            //repeats the terminal

            bool repeatTerminal = true;



            Console.WriteLine("Welcome to the Five Below shop!");

            Console.WriteLine("Here is a menu that you can select from.");

            List <Product> recieptList = new List <Product>();



            //display list

            while (repeatTerminal)

            {
                List <Product> productList = new List <Product>();

                productList = HardList.GetProductList();



                int itemQuantity;

                bool mainRepeat = true;

                string item;

                string anotherOrder;



                Product.DisplayItemList(productList);



                while (mainRepeat)

                {
                    //user selects item

                    Console.WriteLine("\nPlease type in the LETTER of the product you would like to add.");

                    item = Validate.itemLetter(Console.ReadLine());



                    //user selects quantity of the item

                    Console.WriteLine("Please add the quantity of the item chosen.");

                    itemQuantity = Validate.itemQuantity(Console.ReadLine());



                    double total = Compute.LineTotal(Product.SetPrice(item, productList), itemQuantity);



                    //Product item is added to receipt

                    recieptList.Add(Product.AddToReceipt(item, itemQuantity, productList));



                    //notify the customer that item is added to cart and print running total

                    Console.WriteLine(Product.ShowObject(item, recieptList) + " has been added to the list\n");

                    Console.WriteLine($"Your current total is " + Compute.ShowSubtotal().ToString("C2"));



                    //user chooses to add more items or continue to math methods

                    Console.WriteLine("Would you like to add another item (y or n)?");



                    string doAgain = Validate.startAnother(Console.ReadLine());

                    if (doAgain == "n")

                    {
                        mainRepeat = false;
                    }

                    else if (doAgain == "y")

                    {
                        mainRepeat = true;
                    }
                }



                #region Display the lineitems line totals, subtotal, tax, grandtotal



                Console.WriteLine("\n");

                Console.WriteLine("Five Below Bodega\n");

                //var combo = HardList.GetReceiptList().Zip(HardList.quantityList, (a, b) => new { N = a.Name, Price = b });

                foreach (var np in recieptList)

                {
                    Console.WriteLine(np.Quantity + " x " + np.Name + "......." + np.Price.ToString("C2"));
                }



                //gives subtotal (Sum of all LineTotals)

                Console.WriteLine("Subtotal......................" + Compute.ShowSubtotal().ToString("C2"));



                //gives the tax for the receipt total

                Console.WriteLine("Tax..........................." + Compute.Taxtotal(Compute.ShowSubtotal()).ToString("C2"));



                //gives the grandtotal

                Console.WriteLine("Total........................." + Compute.Grandtotal(Compute.ShowSubtotal(), Compute.TaxedAmount(Compute.ShowSubtotal())).ToString("C2") + "\n");

                #endregion



                ////Validate Payment method

                Payment.Money();



                Console.WriteLine("Would you like to place another order (y or n)?");

                anotherOrder = Validate.startAnother(Console.ReadLine());

                if (anotherOrder == "n")

                {
                    repeatTerminal = false;

                    Console.WriteLine("Thank you for shopping!");
                }

                else if (anotherOrder == "y")

                {
                    repeatTerminal = true;
                }
            }
        }
Esempio n. 4
0
        public static void Credit()
        {
            //Start: is below the Next:
Start:
            try
            {
                Console.WriteLine("Please enter your credit card number.");

                string credit = Console.ReadLine();

                if ((Regex.IsMatch(credit, @"(^4\d{15}$)")))
                {
                    Console.WriteLine("Visa Card.. Valid Input");
                    Console.WriteLine("\n");
                    Console.WriteLine("Five Below Bodega Receipt\n");
                    Console.WriteLine("Subtotal......................" + Compute.ShowSubtotal().ToString("C2"));
                    Console.WriteLine("Tax..........................." + Compute.Taxtotal(Compute.ShowSubtotal()).ToString("C2"));
                    Console.WriteLine("Total........................." + Compute.Grandtotal(Compute.ShowSubtotal(), Compute.TaxedAmount(Compute.ShowSubtotal())).ToString("C2"));
                    Console.WriteLine("Visa Card................ ....XXXX");
                    //Next; Jumps down to printing receipt
                }
                else if ((Regex.IsMatch(credit, @"(^5[1-5]\d{14}$)")))
                {
                    Console.WriteLine("Master Card.. Valid Input");
                    Console.WriteLine("\n");
                    Console.WriteLine("Five Below Bodega Receipt\n");
                    Console.WriteLine("Subtotal......................" + Compute.ShowSubtotal().ToString("C2"));
                    Console.WriteLine("Tax..........................." + Compute.Taxtotal(Compute.ShowSubtotal()).ToString("C2"));
                    Console.WriteLine("Total........................." + Compute.Grandtotal(Compute.ShowSubtotal(), Compute.TaxedAmount(Compute.ShowSubtotal())).ToString("C2"));
                    Console.WriteLine("Master Card...............XXXX");
                }
                else if ((Regex.IsMatch(credit, @"(^6(?:011\d\d|5\d{4}|4[4-9]\d{3}|22(?:1(?:2[6-9]|[3-9]\d)|[2-8]\d\d|9(?:[01]\d|2[0-5])))\d{10}$)")))
                {
                    Console.WriteLine("Discover Card.. Valid Input");
                    Console.WriteLine("\n");
                    Console.WriteLine("Five Below Bodega Receipt\n");
                    Console.WriteLine("Subtotal......................" + Compute.ShowSubtotal().ToString("C2"));
                    Console.WriteLine("Tax..........................." + Compute.Taxtotal(Compute.ShowSubtotal()).ToString("C2"));
                    Console.WriteLine("Total........................." + Compute.Grandtotal(Compute.ShowSubtotal(), Compute.TaxedAmount(Compute.ShowSubtotal())).ToString("C2"));
                    Console.WriteLine("Discover..................XXXX");
                }
                else if ((Regex.IsMatch(credit, @"(^3[47]\d{13}$)")))
                {
                    Console.WriteLine("American Express.. Valid Input");
                    Console.WriteLine("\n");
                    Console.WriteLine("Five Below Bodega Receipt\n");
                    Console.WriteLine("Subtotal......................" + Compute.ShowSubtotal().ToString("C2"));
                    Console.WriteLine("Tax..........................." + Compute.Taxtotal(Compute.ShowSubtotal()).ToString("C2"));
                    Console.WriteLine("Total........................." + Compute.Grandtotal(Compute.ShowSubtotal(), Compute.TaxedAmount(Compute.ShowSubtotal())).ToString("C2"));
                    Console.WriteLine("AMEX......................XXXX");
                }
                else
                {
                    Console.WriteLine("Invalid Input");
                    goto Start;
                }
            }
            catch (ArgumentNullException)
            {
                Console.WriteLine("Cannot input nothing.");
                goto Start;
            }
            catch (NullReferenceException)
            {
                Console.WriteLine("Cannot input nothing.");
                goto Start;
            }
            catch (Exception)
            {
                Console.WriteLine("Invalid Input.");
                //goes back to the top asking how to input their card number
                goto Start;
            }
        }