public int CalculateSalary(WorkPerson person, int workedDays)
        {
            var salary = 0;

            if (person == null)
            {
                return(0);
            }

            salary = salaryRules.First(x => x.IsMatch(person)).CalculateSalary(workedDays);

            return(salary);
        }
        public int Calculate(WorkPerson person, int workedDays)
        {
            var limitAge           = 50;
            var salaryByDayUnder50 = 100;
            var salaryByDayOver50  = 120;
            var salary             = 0;

            if (person == null)
            {
                return(0);
            }

            if (person.Age > limitAge)
            {
                salary = workedDays * salaryByDayOver50;
            }
            if (person.Age <= limitAge)
            {
                salary = workedDays * salaryByDayUnder50;
            }

            return(salary);
        }
示例#3
0
 public bool IsMatch(WorkPerson person)
 {
     return(person.Age <= 50);
 }