Example #1
0
        public void Charge(Money price, DiscountProgram discountProgram)
        {
            if (price == null)
            {
                throw new ArgumentNullException(nameof(price));
            }
            if (discountProgram == null)
            {
                throw new ArgumentNullException(nameof(discountProgram));
            }

            var toCredit = discountProgram
                           .GetBestDiscount(DiscountCard)
                           .ApplyOn(price);

            Account = Account.Credit(toCredit);

            DiscountCard = DiscountCard.RegisterPurchase(price);
        }
Example #2
0
 public User(DiscountCard discountCard, Account account)
 {
     DiscountCard = discountCard ?? throw new ArgumentNullException(nameof(discountCard));
     Account      = account ?? throw new ArgumentNullException(nameof(account));
 }