示例#1
0
        public Decimal AddItem(Product product, Decimal quantity)
        {
            if (cardItems.ContainsKey(product))
            {
                if (cardItems[product] + quantity > 0)
                {
                    cardItems[product] += quantity;
                }
                else
                {
                    throw new Exception(product.Name +" quantity should be greater than zero.");
                }

            }
            else
            {
                if (quantity > 0)
                {
                    cardItems.Add(product, quantity);
                }
                else
                {
                    throw new Exception(product.Name + " quantity should be greater than zero.");
                }
            }
            return cardItems[product];
        }
示例#2
0
 public void RemoveItem(Product product)
 {
     cardItems.Remove(product);
 }