/// <summary> /// Add a <see cref="Discount" /> which is mapped to a specific <see cref="Item" />. /// </summary> /// <param name="item">The <see cref="Item" />.</param> /// <param name="discount">The mapped <see cref="Discount" />.</param> public void Add(Item item, Discount discount) { Checks.CheckArgumentNotNull(item, "Item can't be null."); Checks.CheckArgumentNotNull(discount, "Discount can't be null."); discountItems[item] = discount; }
public CheckoutItem(Item item, Discount discount) { Checks.CheckArgumentNotNull(item, "Item is null."); Checks.CheckArgumentNotNull(discount, "Discount is null."); Item = item; Discount = discount; }
/// <summary> /// Add items to checkout. /// </summary> /// <param name="amount">The item amount.</param> /// <param name="item">The item for checkout.</param> public void AddItem(int amount, Item item) { Checks.CheckArgumentNotNull(item, "Item can't be null."); Checks.CheckArgument(amount > 0, "Amount must be > 0."); if (items.TryGetValue(item, out var currentAmount)) { items[item] = currentAmount + amount; } else { items.Add(item, amount); } }