public Get ( string product, int quantity ) : |
||
product | string | The name of the product to obtain |
quantity | int | The desired amount of product |
return |
public Product Get(string product, int quantity)
{
if (Contains(product))
{
// Split the stack
Product productToGive = items[product].Split(quantity);
if (items[product].Quantity <= 0)
{
// Remove product if stack is empty
items.Remove(product);
}
// Recalculate total cost of all items in inventory.
CalculateTotal();
return productToGive;
}
else
{
// Return null if shelf doesn't contain the desired product
return null;
}
}