public void TestApplyDiscount() { IDiscounter target = getTestObject(); decimal total = 100M; var discountedTotal = target.ApplyDiscount(total); Assert.AreEqual(total * 0.8M, discountedTotal); }
/// <summary> /// Add a new Coupon to this store, coupons applicable to items can only have one /// </summary> /// <param name="item">The Coupon to be added</param> public void Add(IDiscounter <ItemBase> item) { if (item.GetType() == typeof(PercentOffCoupon)) { percentOff = (PercentOffCoupon)item; if (percentOff.percent > 100 || percentOff.percent < 0) { percentOff.percent = 0; } return; } if (item.GetType() == typeof(BxGyCoupon)) { var coupon = (BxGyCoupon)item; var existingCoupon = itemDiscounts.FirstOrDefault(i => i.itemName == coupon.itemName); if (existingCoupon != null) { itemDiscounts.Remove(existingCoupon); } itemDiscounts.Add(coupon); } }
public Checkout(IPriceTotalizer priceTotalizer, IDiscounter discounter) { _priceTotalizer = priceTotalizer; _discounter = discounter; }
public Checkout(IDiscounter discounter, IPriceFinder priceFinder) { _discounter = discounter; _priceFinder = priceFinder; _total = 0; }
public PriceCalculator(IDiscounter discounter) { _discounter = discounter; }
/// <summary> /// Apply a discount to this register /// </summary> /// <param name="discount">The discount to be applied</param> public void ApplyDiscount(IDiscounter <ItemBase> discount) { couponStore.Add(discount); }
public ShoppingWithHuaBei(IPriceCounter priceCounter, IDiscounter discounter) : base(priceCounter, discounter) { }
public OnlineShopping(IPriceCounter priceCounter, IDiscounter discounter) { this.counter = priceCounter; this.discounter = discounter; }
public LinqValueCalculator(IDiscounter discounter) { m_discounter = discounter; }
public ShoppingBasket(IDiscounter discounter, Order order) { _discounter = discounter; Order = order; }