Пример #1
0
 public bool HasInventory(InventoryItem inventoryItem, int amount)
 {
     if (this.Inventory.Contains(inventoryItem))
     {
         return (int) this.Inventory[inventoryItem] >= amount;
     }
     return false;
 }
Пример #2
0
 public void Add(InventoryItem inventoryItem, int amount)
 {
     if (this.HasInventory(inventoryItem, amount))
     {
         this.Inventory[inventoryItem] = (int) this.Inventory[inventoryItem] + amount;
     }
     else
     {
         this.Inventory[inventoryItem] = amount;
     }
 }
Пример #3
0
 public void Remove(InventoryItem inventoryItem, int amount)
 {
     if (this.HasInventory(inventoryItem, amount))
     {
         if ((int) this.Inventory[inventoryItem] == amount)
         {
             this.Inventory.Remove(inventoryItem);
         }
         else
         {
             this.Inventory[inventoryItem] = (int) this.Inventory[inventoryItem] - amount;
         }
     }
     else
     {
         throw new InvalidOperationException("The warehouse does not have that item or enough of it");
     }
 }
Пример #4
0
 public Order(InventoryItem inventoryItem, int amount)
 {
     this.Item = inventoryItem;
     this.Amount = amount;
 }