示例#1
0
        public decimal Pay(IPayment payment, int numberOfMoney, string productName)
        {
            ContainableItem containableItem = ProductBand.Instance().GetByName(productName);
            if (_internalAccountant.IsEnoughMoney(containableItem,
                _internalAccountant.TotalAmount(payment, numberOfMoney)))
            {
                Notify(containableItem);

                return payment.GetChange();
                //if (payment is Coin)
                //{
                //    return _internalAccountant.CalculateChange(containableItem.Product.Price, payment, numberOfMoney);
                //}
                //if (payment is CreditCard)
                //{
                //    payment.Amount -= containableItem.Product.Price;
                //    return 0;
                //}
                //if (payment is Banknote)
                //    return 0;
            }
            throw new ArgumentException("You need to enter more money.");
        }
        public void Dispense(ContainableItem containableItem)
        {
            ContainableItem product = ProductBand.Instance().GetByName(containableItem.Product.Name);

            ProductBand.Instance().Remove(product);
        }