public void Add(Product product)
{
// Only store product if it has a quantity greater than 0
if (product.Quantity > 0)
{
// If inventory already has a stack of this product
if (items.ContainsKey(product.Name))
{
// Combine stacks
items[product.Name].Quantity += product.Quantity;
}
else
{
// New entry
items.Add(product.Name, product);
}
// Recalculate the new total cost of all items.
CalculateTotal();
}
}