Ejemplo n.º 1
0
 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";
 }
Ejemplo n.º 2
0
 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                
     ))
 {}
Ejemplo n.º 4
0
 /// <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
     ))
 {}