/// <summary> /// Calculates the net salary, deductions included, /// of the worker; based on the hourly rate and the total hours worked /// minus the deductions applicable depending on the country /// where the worker works. /// </summary> /// <param name="hourlyRate">The rate per hour</param> /// <param name="hoursWorked">The total amount of hours worked</param> /// <param name="taxPlan">An object implementing the ITaxPlan interface</param> /// <returns>Net salary</returns> public static decimal GetNetSalary(decimal hourlyRate, decimal hoursWorked, ITaxPlan taxPlan) { decimal gross = GetGrossSalary(hourlyRate, hoursWorked); gross -= ((TaxPlan)taxPlan).GetTotalDeductions(gross); return(decimal.Round(gross, 2, MidpointRounding.AwayFromZero)); }
/// <summary> /// Mandatory ctor /// Injects the necessary parameters /// </summary> /// <param name="rate">The rate per hour</param> /// <param name="hours">The hours worked</param> /// <param name="plan">The national tax plan</param> public Employee(decimal rate, decimal hours, ITaxPlan plan) { _rate = rate; _hours = hours; _plan = plan; switch (plan.GetType().Name) { case "IrelandTaxPlan": _country = "Ireland"; break; case "GermanyTaxPlan": _country = "Germany"; break; case "ItalyTaxPlan": _country = "Italy"; break; case "CaymanTaxPlan": _country = "Cayman Islands"; break; } }