Exemplo n.º 1
0
        public void AddNewProduct(Product product, int quantity, float price)
        {
            if (!isOpened)
            {
                throw new ShopIsClosedException();
            }
            if (products.ContainsKey(product.GetBarcode()))
            {
                throw new ProductAlreadyExistsException();
            }
            ShopEntryImpl shopEntryImpl = new ShopEntryImpl(product, quantity, price);

            products.Add(product.GetBarcode(), shopEntryImpl);
        }
Exemplo n.º 2
0
 public void AddNewProduct(Product product, int quantity, float price)
 {
     if (IsOpen == false)
     {
         throw new ShopIsClosedException("The shop is closed sorry");
     }
     if (DictProducts.Count >= 1)
     {
         foreach (long element in DictProducts.Keys)
         {
             if (element == product.Barcode)
             {
                 throw new ProductAlreadyExistException("This product is already in the shop");
             }
         }
         ShopEntryImpl shopEntry = new ShopEntryImpl(product, quantity, price);
         DictProducts[product.Barcode] = shopEntry;
     }
     else
     {
         ShopEntryImpl shopEntry = new ShopEntryImpl(product, quantity, price);
         DictProducts[product.Barcode] = shopEntry;
     }
 }