Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is JobAssignment other &&
                   ((JobTitle == null && other.JobTitle == null) || (JobTitle?.Equals(other.JobTitle) == true)) &&
                   ((PayType == null && other.PayType == null) || (PayType?.Equals(other.PayType) == true)) &&
                   ((HourlyRate == null && other.HourlyRate == null) || (HourlyRate?.Equals(other.HourlyRate) == true)) &&
                   ((AnnualRate == null && other.AnnualRate == null) || (AnnualRate?.Equals(other.AnnualRate) == true)) &&
                   ((WeeklyHours == null && other.WeeklyHours == null) || (WeeklyHours?.Equals(other.WeeklyHours) == true)));
        }
        public double CalculateBiWeeklyGrossPay()
        {
            double grossSalary = 0;

            if (PayType.Equals(PayType.SALARY))
            {
                // 52 weeks in a year, two week long pay periods
                grossSalary = Salary / (52 / 2);
            }
            else
            {
                // checking for overtime
                if (HoursWorked > 80)
                {
                    grossSalary = 80 * Salary;
                    double remainingHours = HoursWorked - 80;

                    // checking if over ten overtime hours
                    if (remainingHours > 10)
                    {
                        // first ten overtime hours calculated at 150% hourly salary
                        grossSalary += 10 * Salary * 1.5;

                        // remaining overtime hours calculated at 175% hourly salary
                        grossSalary += (remainingHours - 10) * Salary * 1.75;
                    }
                    else
                    {
                        // ten or less overtime hours, valuing at 150% hourly salary.
                        grossSalary += remainingHours * Salary * 1.5;
                    }
                }
                else
                {
                    grossSalary = HoursWorked * Salary;
                }
            }

            return(Math.Round(grossSalary, 2, MidpointRounding.AwayFromZero));
        }