private void Notify(ContainableItem containableItem) { foreach (var dispenser in _dispensers) { dispenser.Dispense(containableItem); } }
public bool IsEnoughMoney(ContainableItem containableItem, decimal totalAmount) { if (containableItem.Product.Price <= totalAmount) { return(true); } return(false); }
public void Remove(ContainableItem containableItem) { if (_products.Count > 0) { _products.Remove(containableItem); _bandSize += containableItem.Size; } else { throw new BandIsEmptyException("remove"); } }
public void Add(ContainableItem containableItem) { if (_bandSize > 0) { _products.Add(containableItem); _bandSize -= containableItem.Size; } else { throw new BandIsFullException(); } }
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); }