示例#1
0
 public virtual void add(Product product_to_add, int quantity_of_product)
 {
     if (contains_item_for(product_to_add))
     {
         get_item_for(product_to_add).increment_quantity_by(quantity_of_product);
         return;
     }
     items.Add(item_factory.create_item_for(product_to_add, quantity_of_product));
 }
示例#2
0
 public void add(Product product)
 {
     if (already_contains_item_for(product))
     {
         get_item_for(product).increment_quantity();
         return;
     }
     shopping_cart_items.Add(cart_item_factory.create_from(product));
 }
 public virtual void add(Product product, int quantity)
 {
     if (contains_item_for(product))
     {
         get_item_for(product).increment_quantity_by(quantity);
         return;
     }
     items.Add(cart_item_factory.create_item_for(product, quantity));
 }
示例#4
0
 public virtual void add(Product product_to_add, int quantity_of_product)
 {
     if( list_of_products.ContainsKey(product_to_add))
     {
         list_of_products[product_to_add] += quantity_of_product;
     }
     else
     {
         list_of_products.Add(product_to_add,quantity_of_product);
     }
 }
示例#5
0
 public void remove(Product product)
 {
     shopping_cart_items.Remove(get_item_for(product));
 }
示例#6
0
 bool already_contains_item_for(Product product)
 {
     return shopping_cart_items.Any(item => item.is_item_for(product));
 }
示例#7
0
 ShoppingCartItem get_item_for(Product product)
 {
     return shopping_cart_items.FirstOrDefault(item => item.is_item_for(product)) ?? new MissingCartItem();
 }
示例#8
0
 public virtual void modify(Product modified, int quantity)
 {
     Console.WriteLine("quantity" + quantity );
     if( quantity == 0)
         remove(modified);
 }
示例#9
0
文件: Cart.cs 项目: mager18/nbdn
 public void Add(Product item)
 {
     itemsInChart.Add(item);
 }
示例#10
0
 public ShoppingCartItem(Product product, int quantity)
 {
     this.product = product;
     this.quantity = quantity;
 }
 public virtual bool is_item_for(Product product)
 {
     throw new NotImplementedException();
 }
 public void remove(Product product)
 {
     items.Remove(get_item_for(product));
 }
 bool contains_item_for(Product product)
 {
     return items.Any(item => item.is_item_for(product));
 }
示例#14
0
 public virtual void change_quantity(Product product, int new_quantity)
 {
     get_item_for(product).change_quantity_to(new_quantity);
 }
示例#15
0
 CartItem get_item_for(Product product_to_add)
 {
     return items.First(item => item.is_item_for(product_to_add));
 }
示例#16
0
 public void change_quantity(Product product, int new_quantity)
 {
     var item = get_item_for(product);
     item.change_quantity_to(new_quantity);
     if (item.is_empty()) shopping_cart_items.Remove(item);
 }
示例#17
0
 public override bool is_item_for(Product product)
 {
     return false;
 }
示例#18
0
 public virtual bool is_item_for(Product product)
 {
     return this.product == product;
 }
示例#19
0
 public void delete_product_in_cart(Product remove)
 {
     throw new NotImplementedException();
 }
 public void delete_product_in_cart(Product product)
 {
     cart_corral.get_cart().remove( product);
 }
示例#21
0
 public virtual void remove(Product product_to_remove)
 {
     list_of_products.Remove(product_to_remove);
 }
 public virtual ShoppingCartItem create_from(Product product)
 {
     throw new NotImplementedException();
 }