/// <summary> /// Calculation of bonuses for depositing funds /// </summary> /// <param name="money">Input money</param> /// <exception cref="ArgumentException"> /// <paramref name="money"/>is < 0. /// </exception> public void ReplenishmentMoney(decimal money) { if (money < 0) { throw new ArgumentException(nameof(money)); } this.Amount += money; Bonus = Bonus + BonusToReplenishment.GetBonusPoints(this, money); }
/// <summary> /// Calculation of bonuses for deducting funds /// </summary> /// <param name="money">Input money</param> /// <exception cref="ArgumentException"> /// <paramref name="money"/>is < 0. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="money"/>is > balance (amount). /// </exception> public void WithdrawMoney(decimal money) { if (money < 0) { throw new ArgumentException(nameof(money)); } if (money > this.Amount) { throw new ArgumentException(nameof(money)); } this.Amount -= money; int bonusBalance = Bonus - BonusToReplenishment.GetBonusPoints(this, money); Bonus = bonusBalance > 0 ? bonusBalance : 0; }