Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package registrationsystem;
- import java.time.LocalDate;
- import java.time.Period;
- import java.time.temporal.ChronoUnit;
- import java.util.ArrayList;
- import java.util.List;
- public class Instructor {
- //instance string variables that describe the employees' personal information.
- public String FirstName;
- public String LastName;
- public String StreetAddress;
- public String City;
- public String PostalCode;
- //instance int variables that describe the employees' employee Number.
- public int EmployeeNumber;
- //instance LocalDate variable that describe the employees' of date of birth and hiring date.
- public LocalDate DateOfBirth;
- public LocalDate HiringDate;
- //instance variable for the CurrentDate for the Students' Age.
- public static LocalDate CurrentDateOfInstructorsAge = LocalDate();
- private static java.time.LocalDate LocalDate() {
- // TODO Auto-generated method stub
- return null;
- }
- //instance variable for list of courses.
- public List<Course> Courses = new ArrayList<>();
- //constructor for the variables above.
- public Instructor(String FirstName, String LastName, int EmployeeNumber, String StreetAddress,
- String City, String PostalCode, LocalDate HiringDate, LocalDate DateOfBirth) {
- this.FirstName = FirstName;
- this.LastName = LastName;
- this.StreetAddress = StreetAddress;
- this.City = City;
- this.PostalCode = PostalCode;
- this.EmployeeNumber = EmployeeNumber;
- this.DateOfBirth = DateOfBirth;
- this.HiringDate = HiringDate;
- }
- //get FirstName
- public String getFirstName() {
- return FirstName;
- }
- //set FirstName
- public void setFirstName(String FirstName) {
- this.FirstName = FirstName;
- }
- //get LastName
- public String getLastName() {
- return LastName;
- }
- //set LastName
- public void setLastName(String LastName) {
- this.LastName = LastName;
- }
- @Override
- public String toString(){
- return FirstName + LastName;
- }
- //get StreetAddress
- public String getStreetAddress() {
- return StreetAddress;
- }
- //set StreetAddress
- public void setStreetAddress(String StreetAddress) {
- this.StreetAddress = StreetAddress;
- }
- //get for changing the address within the registration system.
- public String getAddress() {
- return StreetAddress + "," +City+","+PostalCode;
- }
- //set for changing the address within the registration system.
- public void changeAddress(String StreetAddress, String City, String PostalCode) {
- this.StreetAddress = StreetAddress;
- this.City = City;
- this.PostalCode = PostalCode;
- }
- //get City
- public String getCity() {
- return City;
- }
- //set City
- public void getCity(String City) {
- this.City = City;
- }
- //get PostalCode
- public String getPostalCode() {
- return PostalCode;
- }
- //set PostalCode
- public void setPostalCode(String PostalCode) {
- this.PostalCode = PostalCode;
- }
- //get EmployeeNumber
- public int getEmployeeNumber() {
- return EmployeeNumber;
- }
- //set EmployeeNumber
- public void setEmployeetNumber(int EmployeeNumber) {
- this.EmployeeNumber = EmployeeNumber;
- }
- //get DateOfBirth
- public LocalDate getDateOfBirth() {
- return DateOfBirth;
- }
- //set DateOfBirth
- public void setDateOfBirth(LocalDate DateOfBirth) {
- int age = Period.between(LocalDate(), DateOfBirth).getYears();
- if(age > 80) {
- throw new IllegalArgumentException("Please check the year entered, instructor cannot be over 100 years old.");
- }else {
- this.DateOfBirth = DateOfBirth;
- }
- }
- //get Instructors' Birthday
- public LocalDate getBirthday() {
- return DateOfBirth;
- }
- //set Instructors' Birthday
- public void setBirthday(LocalDate Birthday) {
- int age = Period.between(LocalDate(), Birthday).getYears();
- if(age > 100) {
- throw new IllegalArgumentException("Please check the year entered, instructor cannot be over 100 years old");
- }else {
- this.DateOfBirth = Birthday;
- }
- }
- //get AgeInYears
- public int getAgeInYears() {
- long diff = ChronoUnit.YEARS.between(DateOfBirth, LocalDate());
- return (int) diff;
- }
- //set AgeInYears
- public void setAgeInYears(LocalDate AgeInYears) {
- this.DateOfBirth = DateOfBirth;
- }
- //get YearsAtCollege
- public int yearsAtCollege() {
- long diff = ChronoUnit.YEARS.between(HiringDate, LocalDate());
- return (int) diff;
- }
- //set YearsAtCollege
- public void setyearsAtCollege(LocalDate YearsAtCollege) {
- this.HiringDate = HiringDate;
- }
- //get list Course
- public List<Course> getCourses() {
- return Courses;
- }
- //set list Course
- public void setCourses(List<Course> Courses) {
- this.Courses = Courses;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement