Advertisement
aida_07

Untitled

Apr 21st, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1. package registrationsystem;
  2.  
  3. import java.time.LocalDate;
  4. import java.time.Period;
  5. import java.time.temporal.ChronoUnit;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8.  
  9.  
  10. public class Instructor {
  11.  
  12. //instance string variables that describe the employees' personal information.
  13. public String FirstName;
  14. public String LastName;
  15. public String StreetAddress;
  16. public String City;
  17. public String PostalCode;
  18.  
  19. //instance int variables that describe the employees' employee Number.
  20. public int EmployeeNumber;
  21.  
  22. //instance LocalDate variable that describe the employees' of date of birth and hiring date.
  23. public LocalDate DateOfBirth;
  24. public LocalDate HiringDate;
  25.  
  26. //instance variable for the CurrentDate for the Students' Age.
  27. public static LocalDate CurrentDateOfInstructorsAge = LocalDate();
  28.  
  29. private static java.time.LocalDate LocalDate() {
  30. // TODO Auto-generated method stub
  31. return null;
  32. }
  33.  
  34. //instance variable for list of courses.
  35. public List<Course> Courses = new ArrayList<>();
  36.  
  37. //constructor for the variables above.
  38. public Instructor(String FirstName, String LastName, int EmployeeNumber, String StreetAddress,
  39. String City, String PostalCode, LocalDate HiringDate, LocalDate DateOfBirth) {
  40. this.FirstName = FirstName;
  41. this.LastName = LastName;
  42. this.StreetAddress = StreetAddress;
  43. this.City = City;
  44. this.PostalCode = PostalCode;
  45. this.EmployeeNumber = EmployeeNumber;
  46. this.DateOfBirth = DateOfBirth;
  47. this.HiringDate = HiringDate;
  48.  
  49. }
  50.  
  51. //get FirstName
  52. public String getFirstName() {
  53. return FirstName;
  54. }
  55.  
  56. //set FirstName
  57. public void setFirstName(String FirstName) {
  58. this.FirstName = FirstName;
  59. }
  60.  
  61. //get LastName
  62. public String getLastName() {
  63. return LastName;
  64. }
  65.  
  66. //set LastName
  67. public void setLastName(String LastName) {
  68. this.LastName = LastName;
  69. }
  70.  
  71. @Override
  72. public String toString(){
  73. return FirstName + LastName;
  74. }
  75.  
  76. //get StreetAddress
  77. public String getStreetAddress() {
  78. return StreetAddress;
  79. }
  80.  
  81. //set StreetAddress
  82. public void setStreetAddress(String StreetAddress) {
  83. this.StreetAddress = StreetAddress;
  84. }
  85.  
  86. //get for changing the address within the registration system.
  87. public String getAddress() {
  88. return StreetAddress + "," +City+","+PostalCode;
  89. }
  90.  
  91. //set for changing the address within the registration system.
  92. public void changeAddress(String StreetAddress, String City, String PostalCode) {
  93. this.StreetAddress = StreetAddress;
  94. this.City = City;
  95. this.PostalCode = PostalCode;
  96. }
  97.  
  98. //get City
  99. public String getCity() {
  100. return City;
  101. }
  102.  
  103. //set City
  104. public void getCity(String City) {
  105. this.City = City;
  106. }
  107.  
  108. //get PostalCode
  109. public String getPostalCode() {
  110. return PostalCode;
  111. }
  112.  
  113. //set PostalCode
  114. public void setPostalCode(String PostalCode) {
  115. this.PostalCode = PostalCode;
  116. }
  117.  
  118. //get EmployeeNumber
  119. public int getEmployeeNumber() {
  120. return EmployeeNumber;
  121. }
  122.  
  123. //set EmployeeNumber
  124. public void setEmployeetNumber(int EmployeeNumber) {
  125. this.EmployeeNumber = EmployeeNumber;
  126. }
  127.  
  128. //get DateOfBirth
  129. public LocalDate getDateOfBirth() {
  130. return DateOfBirth;
  131. }
  132.  
  133. //set DateOfBirth
  134. public void setDateOfBirth(LocalDate DateOfBirth) {
  135. int age = Period.between(LocalDate(), DateOfBirth).getYears();
  136. if(age > 80) {
  137. throw new IllegalArgumentException("Please check the year entered, instructor cannot be over 100 years old.");
  138. }else {
  139. this.DateOfBirth = DateOfBirth;
  140. }
  141. }
  142.  
  143. //get Instructors' Birthday
  144. public LocalDate getBirthday() {
  145. return DateOfBirth;
  146. }
  147.  
  148. //set Instructors' Birthday
  149. public void setBirthday(LocalDate Birthday) {
  150. int age = Period.between(LocalDate(), Birthday).getYears();
  151. if(age > 100) {
  152. throw new IllegalArgumentException("Please check the year entered, instructor cannot be over 100 years old");
  153. }else {
  154. this.DateOfBirth = Birthday;
  155. }
  156. }
  157.  
  158. //get AgeInYears
  159. public int getAgeInYears() {
  160. long diff = ChronoUnit.YEARS.between(DateOfBirth, LocalDate());
  161. return (int) diff;
  162. }
  163.  
  164. //set AgeInYears
  165. public void setAgeInYears(LocalDate AgeInYears) {
  166. this.DateOfBirth = DateOfBirth;
  167. }
  168.  
  169. //get YearsAtCollege
  170. public int yearsAtCollege() {
  171. long diff = ChronoUnit.YEARS.between(HiringDate, LocalDate());
  172. return (int) diff;
  173. }
  174.  
  175. //set YearsAtCollege
  176. public void setyearsAtCollege(LocalDate YearsAtCollege) {
  177. this.HiringDate = HiringDate;
  178. }
  179.  
  180. //get list Course
  181. public List<Course> getCourses() {
  182. return Courses;
  183. }
  184.  
  185. //set list Course
  186. public void setCourses(List<Course> Courses) {
  187. this.Courses = Courses;
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement