12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SecondLibrary
- {
- 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, string workConditions)
- {
- double salary = 0;
- double salaryUp;
- switch (workConditions)
- {
- case "Допустимые":
- salaryUp = 150;
- break;
- case "Вредные":
- salaryUp = 350;
- break;
- case "Опасные":
- salaryUp = 500;
- break;
- default:
- salaryUp = 0;
- break;
- }
- foreach (WorkDay workDay in workDays)
- {
- bool isHolyday = workDay.Date.DayOfWeek == DayOfWeek.Sunday || workDay.Date.DayOfWeek == DayOfWeek.Saturday;
- double daySalary = 0;
- if (workDay.HourCount > 8)
- daySalary = 8 * hourSalary * ((isHolyday) ? 2 : 1) + (workDay.HourCount - 8) * 2 * hourSalary * ((isHolyday) ? 2 : 1);
- else
- daySalary = workDay.HourCount * hourSalary * ((isHolyday) ? 2 : 1);
- salary += daySalary + salaryUp;
- }
- return salary;
- }
- }
- }
|