public static void SelectPaymentMethod(Cart myCart) { Console.WriteLine("\nWhich payment method will you be using today - Cash, Check, or Credit Card?"); string input = Console.ReadLine().ToLower(); while (true) { if (input != "cash" && input != "credit card" && input != "check") { Console.WriteLine("Invalid input. Which payment method would you like to use - Cash, Check, or Credit Card?"); //input = Console.ReadLine(); } if (input == "cash") { CashPayment Cashy = new CashPayment(); double taxRate = .06; Cashy.PayWithCash(myCart, taxRate); ReceiptCash receipt = new ReceiptCash(Cashy, myCart); Console.WriteLine("About to print receipt."); receipt.PrintReceipt(); //ReceiptCash receipt = new ReceiptCash(Cashy); //receipt.PrintReceipt(myCart); break; } else if (input == "check") { CheckPayment check = new CheckPayment(); check.PayWithCheck(myCart); ReceiptCheck receipt = new ReceiptCheck(check, myCart); receipt.PrintReceipt(); //return check; break; } else { CreditCardPayment card = new CreditCardPayment(); card.PayWithCreditCard(myCart); ReceiptCreditCard receipt = new ReceiptCreditCard(card, myCart); receipt.PrintReceipt(); //return card; break; } } }
//OVERLOAD CONSTRUCTOR public ReceiptCheck(CheckPayment checkPayment, Cart cart) { Cart = cart; CheckPayment = checkPayment; }