public static void DisplayCheckoutCart(Receipt receipt, CalculateOrderTotal orderCalculations) { Console.Clear(); ConsoleColor color = ConsoleColor.Red; Console.ForegroundColor = color; Console.WriteLine(); Console.WriteLine("------------------------------- SHOPPING CART -------------------------------"); Console.WriteLine(); Console.WriteLine(string.Format("{0,-5} {1, -9} {2,-30} {3,-5} {4, 10} {5, 10}", "", "ID", "Name", "Quantity", "Unit Price", "Item Subtotal")); int i = 0; foreach (var item in receipt.ReceiptLineItemsList) { Console.WriteLine(string.Format("{0,-5} {1, -9} {2,-30} {3,-5} {4, 10:C2} {5, 10:C2}", i + 1 + ".)", item.LiquorId, item.LiquorName, item.Quantity, item.UnitPrice, item.LineItemSubtotal)); i++; } Console.WriteLine(); Console.WriteLine("---------------------------"); Console.WriteLine(string.Format("{0, -15} {1} ", "Total units:", orderCalculations.LiquorOrderListForCalculations.Count)); Console.WriteLine(string.Format("{0, -15} {1:C2} ", "Subtotal:", orderCalculations.Subtotal)); Console.WriteLine(string.Format("{0, -15} {1:C2} ", "Sales Tax:", orderCalculations.SalesTaxAmount)); Console.WriteLine(string.Format("{0, -15} {1:C2} ", "Grandtotal:", orderCalculations.GrandTotal)); Console.WriteLine("---------------------------"); }
public void ProcessCreditCardPayment(CalculateOrderTotal orderCalculation) { bool isCardNumberValid = false; bool isExpirationDateValid = false; bool isCardCvvValid = false; isCardNumberValid = ValidatePaymentInput("Please enter your credit card number (16 digits, no symbols): ", new Regex(@"(^[0-9]{16})$"), 3); if (isCardNumberValid == true) { isExpirationDateValid = ValidatePaymentInput("Please enter expiration date (mm/yyyy): ", new Regex(@"(0[1-9]|10|11|12)/[2]{1}[0-9]{3}$"), 3); } if (isCardNumberValid == true && isExpirationDateValid == true) { isCardCvvValid = ValidatePaymentInput("Please enter 3-digit CVV: ", new Regex(@"(^[0-9]{3})$"), 3); } if (isCardNumberValid == true && isExpirationDateValid == true && isCardCvvValid == true) { Console.WriteLine("Credit card payment successful"); PaymentMethod = PaymentMethodEnum.CreditCard; orderCalculation.AmountPaid = orderCalculation.GrandTotal; PaymentDate = DateTime.Now; PaymentStatus = PaymentStatusEnum.Complete; } else { Console.WriteLine(); Console.WriteLine("Credit card payment failed"); Console.WriteLine("Please try again ..."); Console.ReadLine(); } }
public void ProcessCheckPayment(CalculateOrderTotal orderCalculation) { bool isRoutingNumberValid = false; bool isAccountNumberValid = false; isRoutingNumberValid = ValidatePaymentInput("Please enter in your routing number (8-10 digits): ", new Regex("^[0-9]{8,10}$"), 3); if (isRoutingNumberValid == true) { isAccountNumberValid = ValidatePaymentInput("Please enter in your account number (10-17 digits): ", new Regex("^[0-9]{10,17}$"), 3); } if (isRoutingNumberValid == true && isAccountNumberValid == true) { Console.WriteLine("Checking Information Valid"); orderCalculation.AmountPaid = orderCalculation.GrandTotal; PaymentMethod = PaymentMethodEnum.Check; PaymentDate = DateTime.Now; PaymentStatus = PaymentStatusEnum.Complete; } else { Console.WriteLine(); Console.WriteLine("Checking account info failed"); Console.WriteLine("Please try again ..."); Console.ReadLine(); } }
public Receipt(CalculateOrderTotal calculatedOrder) { LiquorListForReceipt = calculatedOrder.LiquorOrderListForCalculations; ReceiptLineItemsList = new List <ReceiptLineItem>(); UpdateReceiptLineItems(); PaymentStatus = PaymentStatusEnum.Pending; }
public double ProcessCashPayment(CalculateOrderTotal orderCalculation) { var calc = new CalculateOrderTotal(); bool checkcash = true; while (checkcash == true) { Console.Write("Please enter the payment amount: $"); bool isUserEnteredCashADouble = double.TryParse(Console.ReadLine(), out userEnteredCash); if (isUserEnteredCashADouble == false) { Console.WriteLine("You entered invalid amount!"); checkcash = true; } else if (orderCalculation.DoesUserHaveEnoughCashFunds(userEnteredCash)) { Console.WriteLine("Enough funds"); PaymentMethod = PaymentMethodEnum.Cash; PaymentDate = DateTime.Now; PaymentStatus = PaymentStatusEnum.Complete; checkcash = false; } else { Console.WriteLine("the payment amount wasn't enough!!"); checkcash = true; } } return(userEnteredCash); }
public double ProcessCashPayment() { var calc = new CalculateOrderTotal(); bool checkcash = true; while (checkcash == true) { Console.WriteLine("Please enter the payment amount : "); bool isUserEnteredCashADouble = double.TryParse(Console.ReadLine(), out userEnteredCash); if (isUserEnteredCashADouble == false) { Console.WriteLine("You entered invalid amount!"); checkcash = true; } else if (calc.DoesUserHaveEnoughCashFunds(userEnteredCash)) { Console.WriteLine("Enough funds"); checkcash = false; } else { Console.WriteLine("the payment amount wasn't enough!! ."); checkcash = true; } } return(userEnteredCash); }
public static Enum DisplayMainMenu(OrderedItems order, CalculateOrderTotal calculatedOrder) { Console.Clear(); HennyArt.DisplayHennyArt(); MenuView.DisplayCartSummary(order, calculatedOrder); ConsoleColor color = ConsoleColor.Magenta; Console.ForegroundColor = color; Console.WriteLine(); Console.WriteLine("-- Main Menu --"); color = ConsoleColor.Yellow; Console.ForegroundColor = color; Console.WriteLine("1). Display Inventory"); Console.WriteLine("2). Add Product to Order"); Console.WriteLine("3). Liquor Info Center"); Console.WriteLine("4). Cash Out"); Console.WriteLine("5). New Order"); Console.WriteLine("6). Quit"); Console.WriteLine(); Console.Write("Select an option: "); if (Enum.TryParse <MenuEnum>(Console.ReadLine(), out var userMenuSelection)) { return(userMenuSelection); } return(null); }
public static void DisplayTransactionRecord(Receipt receipt, CalculateOrderTotal orderCalculations) { Console.Clear(); ConsoleColor color = ConsoleColor.Red; Console.ForegroundColor = color; Console.WriteLine("----------------------------- TRANSACTION RECORD -----------------------------"); Console.WriteLine(); color = ConsoleColor.DarkCyan; Console.ForegroundColor = color; Console.WriteLine(string.Format("{0,-5} {1, -9} {2,-30} {3,-5} {4, 10} {5, 10}", "", "ID", "Name", "Quantity", "Unit Price", "Item Subtotal")); int i = 0; foreach (var item in receipt.ReceiptLineItemsList) { Console.WriteLine(string.Format("{0,-5} {1, -9} {2,-30} {3,-5} {4, 10:C2} {5, 10:C2}", i + 1 + ".)", item.LiquorId, item.LiquorName, item.Quantity, item.UnitPrice, item.LineItemSubtotal)); i++; } Console.WriteLine(); Console.WriteLine("---------------------------"); Console.WriteLine(string.Format("{0, -15} {1} ", "Total units:", orderCalculations.LiquorOrderListForCalculations.Count)); Console.WriteLine(string.Format("{0, -15} {1:C2} ", "Subtotal:", orderCalculations.Subtotal)); Console.WriteLine(string.Format("{0, -15} {1:C2} ", "Sales Tax:", orderCalculations.SalesTaxAmount)); Console.WriteLine(string.Format("{0, -15} {1:C2} ", "Grandtotal:", orderCalculations.GrandTotal)); Console.WriteLine("---------------------------"); Console.WriteLine(string.Format("{0, -15} {1} ", "Payment Method:", receipt.PaymentMethod)); Console.WriteLine(string.Format("{0, -15} {1} ", "Payment Date:", receipt.PaymentDate)); Console.WriteLine(string.Format("{0, -15} {1} ", "Payment Status:", receipt.PaymentStatus)); Console.WriteLine("---------------------------"); switch (receipt.PaymentMethod) { case PaymentMethodEnum.Cash: DisplayCashPaymentDetails(receipt, orderCalculations); break; case PaymentMethodEnum.CreditCard: DisplayCreditPaymentDetails(receipt, orderCalculations); break; case PaymentMethodEnum.Check: DisplayCheckPaymentDetails(receipt, orderCalculations); break; default: break; } Console.WriteLine("---------------------------"); Console.ResetColor(); }
public static void Run() { InfoCenter infoCenter = new InfoCenter(); Controller obj = new Controller(); OrderedItems customerOrder = new OrderedItems(); CalculateOrderTotal orderCalculations = new CalculateOrderTotal(customerOrder); customerOrder.SalesTaxAmount = 0.06; bool userWantsToQuit = false; do { switch (Menu.DisplayMainMenu(customerOrder, orderCalculations)) { case MenuEnum.DisplayInventory: var entireMenuList = new MenuView(obj.Menu); entireMenuList.DisplayLiquorMenu(); break; case MenuEnum.AddProductToOrder: obj.BuyProduct(obj, customerOrder); customerOrder.RecalculateOrderTotals(); break; case MenuEnum.LiquorInfoCenter: infoCenter.Alcohol(); break; case MenuEnum.CashOut: customerOrder.RecalculateOrderTotals(); Receipt receiptObj = new Receipt(orderCalculations); MenuView.DisplayCheckOutCart(receiptObj, orderCalculations); receiptObj.SelectPaymentOption(); break; case MenuEnum.Quit: Console.WriteLine("Bye!"); userWantsToQuit = true; break; default: Console.WriteLine("Try again"); break; } Console.WriteLine("\n... press any key to continue ..."); Console.ReadKey(); } while (userWantsToQuit.Equals(false)); Console.ReadLine(); }
public void SelectPaymentMethod(CalculateOrderTotal orderCalculation) { bool run = true; while (run == true) { ConsoleColor color = ConsoleColor.Cyan; Console.ForegroundColor = color; Console.Write("How would you like to pay?\n1.) Cash\n2.) Credit Card\n3.) Check"); Console.WriteLine(); int input = 0; color = ConsoleColor.Red; Console.ForegroundColor = color; bool option = int.TryParse(Console.ReadLine(), out input); if (option == false) { Console.WriteLine("Sorry didn't understand input!"); run = true; } else if (input >= 1 && input <= 3) { run = false; } else { Console.WriteLine("I'm sorry! That was an invalid option."); run = true; } if (input == 1) { ProcessCashPayment(orderCalculation); } else if (input == 2) { ProcessCreditCardPayment(orderCalculation); } else if (input == 3) { ProcessCheckPayment(orderCalculation); } } }
public static void DisplayCheckOutCart(Receipt receipt, CalculateOrderTotal orderCalculations) { Console.WriteLine(); Console.WriteLine("------------------------------- SHOPPING CART -------------------------------"); Console.WriteLine(); Console.WriteLine(string.Format("{0,-5} {1, -9} {2,-30} {3,-5} {4, 10} {5, 10}", "", "ID", "Name", "Quantity", "Unit Price", "Item Subtotal")); int i = 0; foreach (var item in receipt.ReceiptLineItemsList) { Console.WriteLine(string.Format("{0,-5} {1, -9} {2,-30} {3,-5} {4, 10:C2} {5, 10:C2}", i + 1 + ".)", item.LiquorId, item.LiquorName, item.Quantity, item.UnitPrice, item.LineItemSubtotal)); i++; } Console.WriteLine(); Console.WriteLine("---------------------------"); Console.WriteLine($"Total units in cart: {receipt.LiquorListForReceipt.Count}"); Console.WriteLine(string.Format("{0} {1:C2} ", "Subtotal: ", orderCalculations.subtotal)); Console.WriteLine("---------------------------"); }
public static void DisplayCartSummary(OrderedItems order, CalculateOrderTotal calculatedOrder) { Console.WriteLine(string.Format("{0, 70} {1} {2, 15} {3:C2}", "Items in cart: ", order.LiquorOrderList.Count, "Subtotal: ", order.SubTotal)); }
public static void DisplayCreditPaymentDetails(Receipt receipt, CalculateOrderTotal orderCalculations) { Console.WriteLine(string.Format("{0, -15} {1:C2} ", "Credit Amt Paid:", orderCalculations.AmountPaid)); }
//public Receipt() //{ // //this.calculation = calculation; // var LiquorOrderedList = new List<Liquor>(); // var calculations = new CalculateOrderTotal(); // LiquorListForReceipt = calculations.liquorOrderList; //} //added a new constructor to take in an OrderedItem object -mattyo //public Receipt(OrderedItems orderedItems) //{ // LiquorListForReceipt = orderedItems.LiquorOrderList; //} public Receipt(CalculateOrderTotal calculatedOrder) { LiquorListForReceipt = calculatedOrder.liquorOrderList; ReceiptLineItemsList = new List <ReceiptLineItem>(); UpdateReceiptLineItems(); }