public Coupon(int discount, DateTime expiry) { if (expiry < DateTime.Today) { throw new ArgumentException("Coupon must be constructed with valid expiry date"); } _expiry = expiry; _discount = discount; // Because coupon states are internal, we will // couple them with the specific states so they // are highly cohesive. For this implementation, // we will construct on state change. _currentState = new ValidCouponState(); }
public void SetCouponState(ICouponState state) { _currentState = state; }