WorkPaymentCalculator.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace SecondLibrary
  7. {
  8. public class WorkPaymentCalculator
  9. {
  10. public class WorkDay
  11. {
  12. public DateTime Date { get; set; }
  13. public int HourCount { get; set; }
  14. }
  15. public static double CalculateSalary(double hourSalary, List<WorkDay> workDays, string workConditions)
  16. {
  17. double salary = 0;
  18. double salaryUp;
  19. switch (workConditions)
  20. {
  21. case "Допустимые":
  22. salaryUp = 150;
  23. break;
  24. case "Вредные":
  25. salaryUp = 350;
  26. break;
  27. case "Опасные":
  28. salaryUp = 500;
  29. break;
  30. default:
  31. salaryUp = 0;
  32. break;
  33. }
  34. foreach (WorkDay workDay in workDays)
  35. {
  36. bool isHolyday = workDay.Date.DayOfWeek == DayOfWeek.Sunday || workDay.Date.DayOfWeek == DayOfWeek.Saturday;
  37. double daySalary = 0;
  38. if (workDay.HourCount > 8)
  39. daySalary = 8 * hourSalary * ((isHolyday) ? 2 : 1) + (workDay.HourCount - 8) * 2 * hourSalary * ((isHolyday) ? 2 : 1);
  40. else
  41. daySalary = workDay.HourCount * hourSalary * ((isHolyday) ? 2 : 1);
  42. salary += daySalary + salaryUp;
  43. }
  44. return salary;
  45. }
  46. }
  47. }