Пример #1
0
        public void Pay(double total)
        {
            Console.Clear();
            Console.WriteLine($"Your total is: ${NumberToDollarFormat.Execute(total)}, Please enter how much cash you will be recieved: ");
            cashGiven = CashReceived();

            //Console.WriteLine($"Your total is: {total}, Please enter how much cash you will be giving: ");
            //cashGiven = CashReceived();


            while (cashGiven < total)
            {
                if (cashGiven < total)
                {
                    Console.Clear();
                    Console.WriteLine("I apologize, however the funds provided are insufficient.");
                }
                Console.WriteLine($"Your total is: ${NumberToDollarFormat.Execute(total)}, Please enter how much cash will be recieved: ");
                cashGiven = CashReceived();
            }
            if (cashGiven >= total)
            {
                Console.Clear();
                change = cashGiven - total;
                Console.WriteLine($"Total Change: $" + NumberToDollarFormat.Execute(change));
            }
        }
        public void Pay(double total)
        {
            Console.Clear();
            Console.WriteLine($"Total: ${NumberToDollarFormat.Execute(total)}\n"); //might not need based on how user interface is set up
            Console.WriteLine("Please choose a Card Type: \n[1] VISA \n[2] MASTER \n[3] DISC \n[4] AMEX");


            while (true)
            {
                string cardType   = Console.ReadLine();         // USER VALIDATION, possibly use TryCatch
                bool   ignoreCase = true;

                if (Enum.TryParse <CardTypes>(cardType, ignoreCase, out CardTypes result))
                {
                    cardEnum = result;
                    if (cardEnum == CardTypes.VISA | cardEnum == CardTypes.MASTER | cardEnum == CardTypes.DISC)
                    {
                        Console.Write("\nPlease enter the credit card number(no dashes or spaces): ");
                        CardNumber = ValidateCardNumber1(Console.ReadLine());


                        Console.Write("\nExpiration Date (MM/YY) or (MM/YYYY): ");
                        ExpirationDate = ValidateExpDate(Console.ReadLine());


                        Console.Write("\nCVV: ");
                        CVVCode = ValidateCVVCode1(Console.ReadLine());


                        Console.WriteLine("Your transaction has been processed.");
                        break;
                    }
                    else if (cardEnum == CardTypes.AMEX)
                    {
                        Console.Write("\nPlease enter the credit card number(no dashes or spaces): ");
                        CardNumber = ValidateCardNumber2(Console.ReadLine());


                        Console.Write("\nExpiration Date (MM/YY) or (MM/YYYY): ");
                        ExpirationDate = ValidateExpDate(Console.ReadLine());


                        Console.Write("\nCVV:");
                        CVVCode = ValidateCVVCode2(Console.ReadLine());


                        Console.WriteLine("Your transaction has been processed.");
                        break;
                    }
                    else
                    {
                        Console.WriteLine("This is not a valid card type. Please try again.");
                        continue;
                    }
                }
            }
        }
        public void Pay(double total)
        {
            Console.WriteLine($"Total: ${NumberToDollarFormat.Execute(total)}\n"); //might not need based on how user interface is set up

            Console.WriteLine("Check Number:\n");                                  //validation
            AccountNumber = ValidateCheckNumber(Console.ReadLine());

            Console.WriteLine("Routing Number:\n");     //validation
            RoutingNumber = ValidateRouteNumber(Console.ReadLine());

            Console.WriteLine("Your transaction has been processed.");
        }
        public void PrintReceipt()
        {
            int i = 1;

            Console.WriteLine("\nThank you for shopping with us");
            Console.WriteLine("Printing Recepit for you.....");
            Console.WriteLine("\n");

            foreach (var item in UserShoppingCart)
            {
                //Console.WriteLine($"{item.NameOfItem}");
                //Console.WriteLine($"{item.ItemCategory}");
                //Console.WriteLine($"{item.ItemQuantity}");
                Console.WriteLine("{0,-20} {1,-10:N1} {2,-15:N1} {3,15}", $"{i} {item.NameOfItem}", $"{item.ItemCategory}", $"Quantity: {item.ItemQuantity}", $"Price per Item: ${NumberToDollarFormat.Execute(item.ItemPrice)}");
                i++;
            }
            Console.WriteLine("\n");
            Console.WriteLine($"Subtotal: ${/*userPayments.SubTotal*/NumberToDollarFormat.Execute(ReceiptSubTotal)}");
            Console.WriteLine($"GrandTotal: ${/*userPayments.GrandTotal*/NumberToDollarFormat.Execute(ReceiptGrandTotal)}");
        }
        public void DisplayCart()
        {
            int i = 1;

            Console.WriteLine("So far in your cart you have the following:\r");
            foreach (var item in ItemstoPurchase)
            {
                Console.WriteLine("{0,-20} {1,-10:N1}", $"{i}. {item.NameOfItem}", $"{item.ItemQuantity} x ${NumberToDollarFormat.Execute(item.ItemPrice)} = ${NumberToDollarFormat.Execute(item.ItemPrice*item.ItemQuantity)}");
                i++;
            }
            Console.WriteLine();
        }
        public void categorySelector(StoreInventory currentInventory, ShoppingCart userCart)
        {
            currentInventory.GenerateStoreInventory(userCart);


            Console.Clear();
            Console.WriteLine("Which item would you like to purchase? (Select from the folowing numbers)");

            int i = 1;

            foreach (var item in currentInventory.TotalStoreInventory)
            {
                if (item.ItemCategory == categories[userMenuSelection - 1])
                {
                    Console.WriteLine("{0,-20} {1,-10:N1} {2,10}", $"{i} {item.NameOfItem}", $"QTY: {item.ItemQuantity}", $"Price: ${NumberToDollarFormat.Execute(item.ItemPrice)}");
                    tempList.Add(item);
                    i++;
                }
            }

            DislayListOfItems(userCart);
        }
Пример #7
0
 public void PrintCashInfo()
 {
     Console.WriteLine("Thank you for your cash payment");
     Console.WriteLine($"Cash given: ${NumberToDollarFormat.Execute(cashGiven)}");
     Console.WriteLine($"Change: ${NumberToDollarFormat.Execute(change)}");
 }
        public void MethodOfPayment()
        {
            Console.Clear();


            Console.WriteLine("Thank you for your order! One second while we fetch your total...");

            Console.WriteLine($"Subtotal: ${NumberToDollarFormat.Execute(SubTotal)}");
            Console.WriteLine($"Tax: ${NumberToDollarFormat.Execute(SalesTaxTotal)}");
            Console.WriteLine($"Grand Total: ${NumberToDollarFormat.Execute(GrandTotal)}");
            Console.WriteLine();

            Console.WriteLine("Please select a method of payment (enter a number): " +
                              "\n [1] Credit Card" +
                              "\n [2] Cash" +
                              "\n [3] Check");
            string readingInput = Console.ReadLine();


            //validating input with an enum try parse

            bool isInvalidInput = true;

            //While the input is invalid this loop will continue to run
            while (isInvalidInput)
            {
                if (Enum.TryParse <PaymentSelection>(readingInput, out PaymentSelection userPaymentSelection))
                {
                    switch (userPaymentSelection)
                    {
                    case PaymentSelection.CreditCard:
                        Console.Clear();
                        CreditCard userCreditCard = new CreditCard();
                        userCreditCard.Pay(GrandTotal);
                        Receipt userReceipt = new Receipt(GrandTotal, SubTotal, userShoppingCart.ItemstoPurchase);
                        userReceipt.PrintReceipt();
                        Console.WriteLine("Thank you for your payment from the following credit card");
                        Console.WriteLine("Payment is processed and approved");
                        userCreditCard.printCardInfo();
                        return;

                    case PaymentSelection.Cash:
                        Console.Clear();
                        Cash userCash = new Cash();
                        userCash.Pay(GrandTotal);
                        Receipt cashUserReceipt = new Receipt(GrandTotal, SubTotal, userShoppingCart.ItemstoPurchase);
                        cashUserReceipt.PrintReceipt();
                        userCash.PrintCashInfo();
                        return;

                    case PaymentSelection.Check:
                        Console.Clear();
                        Check userCheck = new Check();
                        userCheck.Pay(GrandTotal);
                        Receipt checkUserReceipt = new Receipt(GrandTotal, SubTotal, userShoppingCart.ItemstoPurchase);
                        checkUserReceipt.PrintReceipt();
                        userCheck.PrintCheckInfo();
                        return;

                    default:
                        Console.WriteLine("I'm sorry but we do not accept this form of payment.");
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("ERROR invalid input please enter again: ");
                    Console.WriteLine("Please selece a method of payment [Select 1-3]: " +
                                      "\n [1] Credit Card" +
                                      "\n [2] Cash" +
                                      "\n [3] Check" +
                                      "\n Enter x to return to the main menu");
                    readingInput = Console.ReadLine();
                    if (readingInput == "x")
                    {
                        StoreApp takeBackToMenu = new StoreApp();
                        takeBackToMenu.RunStore();
                    }
                }
            }
        }