public bool HasInventory(InventoryItem inventoryItem, int amount) { if (this.Inventory.Contains(inventoryItem)) { return (int) this.Inventory[inventoryItem] >= amount; } return false; }
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; } }
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"); } }
public Order(InventoryItem inventoryItem, int amount) { this.Item = inventoryItem; this.Amount = amount; }