Beispiel #1
0
 public static Campaign GenerateCampaign(Category category, uint minItems, decimal discountQuantity, DiscountType discountType)
 {
     if (discountType == DiscountType.Amount)
     {
         AmountDiscountStrategy amountDiscountStrategy = new AmountDiscountStrategy();
         return(new Campaign(category, minItems, discountQuantity, amountDiscountStrategy));
     }
     else if (discountType == DiscountType.Rate)
     {
         RateDiscountStrategy rateDiscountStrategy = new RateDiscountStrategy();
         return(new Campaign(category, minItems, discountQuantity, rateDiscountStrategy));
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Beispiel #2
0
 public static Coupon GenerateCoupon(decimal minAmount, decimal discountQuantity, DiscountType discountType)
 {
     if (discountType == DiscountType.Amount)
     {
         AmountDiscountStrategy amountDiscountStrategy = new AmountDiscountStrategy();
         return(new Coupon(minAmount, discountQuantity, amountDiscountStrategy));
     }
     else if (discountType == DiscountType.Rate)
     {
         RateDiscountStrategy rateDiscountStrategy = new RateDiscountStrategy();
         return(new Coupon(minAmount, discountQuantity, rateDiscountStrategy));
     }
     else
     {
         throw new NotImplementedException();
     }
 }