public void RequestProduct(Product product) { if (product == Product.Cola && Total >= 100) DispenseProduct(product, 100); else if (product == Product.Candy && Total >= 65) DispenseProduct(product, 65); else Display = "INSERT MORE COINS"; }
private void DispenseProduct(Product product, int cost) { Display = "THANK YOU"; DispensedProducts.Add(product); ReturnedCoins = _calculateChange.ChangeFor(Total - cost) .Select(coin => coin.ToString()) .ToList(); Total = 0; }
public ProductsLessThanNecessaryException(Product product, uint containCount, uint necessaryCount) : base(String.Format( "Vending machine contains {0} products with name {1}. And you need {2} products with name {3}.", containCount, product.Name, necessaryCount, product.Name )) {}
/// <summary> /// Удаление купленного товара из автомата /// </summary> /// <param name="product">товар</param> public void DeletiongBoughtProduct(Product product) { Products.RemoveAt(Products.FindLastIndex(x=> x==product)); }
public NoSuchProductException(Product product) : base(String.Format( "There is no product with name = \"{0}\" in vending machine.", product.Name )) {}