예제 #1
0
        public void Pay(int productId, int option)
        {
            Product product = dispenser.GetProductViaID(productId);

            if (option == 1)
            {
                payment = new CoinPayment();
            }
            else if (option == 2)
            {
                payment = new BanknotePayment();
            }
            else if (option == 3)
            {
                payment = new CardPayment();
            }
            else
            {
                throw new MyException("1,2 or 3...so simple and yet so complicated");
            }
            if (payment.Change(product.Price))
            {
                if (payment.IsValid)
                {
                    paymentEvent.Notify(productId);
                }
            }
        }
 public void Pay(Boolean cardMode, int Id, Decimal price, Coin coin = null, Banknote banknote = null, CreditCard creditCard = null, int pin = 0)
 {
     //CardMode is "false" for cash payment and "true" for card payment
     if (cardMode)
     {
         CollectCreditCard(creditCard, pin, price);
     }
     else
     {
         CollectCash(coin, banknote, price);
     }
     paymentEvent.Notify(Id);
 }