コード例 #1
0
 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();
 }
コード例 #2
0
 public void SetCouponState(ICouponState state)
 {
     _currentState = state;
 }