public Tax(int year, TaxRule tRule, PaymentRule pRule) { Year = year > 2000 ? year : throw new ArgumentOutOfRangeException(nameof(year)); tRule = tRule != null ? tRule : throw new ArgumentOutOfRangeException(nameof(tRule)); Year = year; TRule = tRule; PRule = pRule; }
//DDD-styled entity class you can only create/change data via specific constructors/methods public PaymentData(string employeeName, int anualSalary, double superRate, string payPeriod, TaxRule taxRule) { _anualSalary = anualSalary; _taxRule = taxRule; PayPeriod = payPeriod; EmployeeName = employeeName; //set up Tier SetUpTier(); //gross income var Val = (double)anualSalary / 12; GrossIncome = RoundUpAmount(Val); //income tax TaxAmount = RoundUpAmount((double)(_TaxFixedAmount + (double)((anualSalary - _TierAmount) * (_Rate / 100))) / 12); //NetIncome NetIncome = GrossIncome - TaxAmount; //Super SuperAmount = RoundUpAmount((double)(GrossIncome * superRate) / 100); }