Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. /*
  2. * Created by SharpDevelop.
  3. * User: User
  4. * Date: 01.10.2016
  5. * Time: 20:12
  6. *
  7. * To change this template use Tools | Options | Coding | Edit Standard Headers.
  8. */
  9. using System;
  10.  
  11. namespace EMPLOYEE
  12. {
  13. /// <summary>
  14. /// Description of Employee.
  15. /// </summary>
  16. public class Employee : User
  17. {
  18. DateTime employment_date;
  19. string specialty;
  20.  
  21. protected static string check_specialty(string check_str)
  22. {
  23. if (String.IsNullOrEmpty(check_str))
  24. {
  25. throw new ArgumentException("Должность или специальность не может быть null или пустой строкой");
  26. }
  27. char[] arname = check_str.ToCharArray();
  28. for (int i = 1; i < arname.Length; i++)
  29. {
  30. arname[i] = char.ToLower(arname[i]);
  31. }
  32. arname[0] = char.ToUpper(arname[0]);
  33. return new string(arname);
  34. }
  35.  
  36. static DateTime check_employment_date(DateTime date, int age)
  37. {
  38. if (date > DateTime.Now)
  39. {
  40. throw new ArgumentException("Дата не может быть в будущем");
  41. }
  42. if (GetYear(date) > age)
  43. {
  44. throw new ArgumentException("Дата такова, что стаж больше возраст человека");
  45. }
  46. return date;
  47. }
  48.  
  49. public int Work_experience
  50. {
  51. get
  52. {
  53. return GetYear(employment_date);
  54. }
  55. }
  56.  
  57. public DateTime Employment_date
  58. {
  59. get
  60. {
  61. return employment_date;
  62. }
  63. set
  64. {
  65. employment_date = check_employment_date(value, Age);
  66. }
  67. }
  68.  
  69. public string Specialty
  70. {
  71. get
  72. {
  73. return specialty;
  74. }
  75. set
  76. {
  77. specialty = check_specialty(value);
  78. }
  79. }
  80.  
  81. public Employee(string specialty, DateTime employment_date ,string name, string surname, string middle_name, DateTime date_of_birth)
  82. : base(name, surname, middle_name, date_of_birth)
  83. {
  84. Employment_date = employment_date;
  85. Specialty = specialty;
  86. }
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement