12345678910111213141516171819202122232425262728293031323334 |
- using System;
- using System.Collections.Generic;
- namespace FirstLibrary
- {
- public class WorkPaymentCalculator
- {
- public class WorkDay
- {
- public DateTime Date { get; set; }
- public int HourCount { get; set; }
- }
- public static double CalculateSalary(double hourSalary, List<WorkDay> workDays, int experience)
- {
- double salary = 0;
- double kExperience = (experience < 5)? 1d : (experience >= 5 && experience < 10)? 1.1d : 1.2d;
- foreach (WorkDay workDay in workDays)
- {
- double daySalary = 0;
- bool isHolyday = workDay.Date.DayOfWeek == DayOfWeek.Sunday || workDay.Date.DayOfWeek == DayOfWeek.Saturday;
- if(workDay.HourCount > 8)
- daySalary = 8 * hourSalary * (isHolyday ? 2 : 1) + (workDay.HourCount - 8) * hourSalary * 2 * (isHolyday ? 2 : 1);
- else
- daySalary = workDay.HourCount * hourSalary * (isHolyday ? 2 : 1);
- salary += daySalary;
- }
- return salary * kExperience;
- }
- }
- }
|