示例#1
0
        public void addItem(Product product, int quantity)
        {
            if (product == null)
            {
                throw new ArgumentNullException("Product is Null");
            }

            if (quantity > 0)
            {
                if (ShoppingCartItems.ContainsKey(product))
                {
                    ShoppingCartItems[product] += quantity;
                }
                else
                {
                    ShoppingCartItems.Add(product, quantity);
                }
            }
        }