Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Java AND please include comments to provide and understandinbof implementa

ID: 3859631 • Letter: U

Question

Using Java AND please include comments to provide and understandinbof implementation.
Requirements Implement classes Person, Student, Employee, Faculty and Staff. These represent the people and categories of people you might find at a college or university. These are related by inheritance as follows Employee and Student both extend Person Faculty and Staff both extend Employee . . Here are the instance fields of each class: Class Instance Fields Person email address name salary Employee date hired Faculty office hours Staff title Student class status Here are the notes from the table: A. This should be a string. The most common values will be one of "FR" SO", JR", "SE", but don't bother testing for that. B. Use the standard Java Date class

Explanation / Answer

Java Code :


import java.util.Date;

class Person {

//Instance variables of the class
String name, email;

//Constructor to set name and email
public Person(String name, String email) {
this.name = name;
this.email = email;
}

//Getters and setters of the instance variables
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

//ToString method prints the name of the class and name of the person
@Override
public String toString() {
return "Person : " + name;
}

}

class Employee extends Person {

//Instance variable
int sal;
Date hired;

//This constructor calls super class constructor to set name and email.
//Initializes date hired to the current date
public Employee(int sal, String name, String email) {
super(name, email);
this.sal = sal;
this.hired = new Date();
}

//Getters and setters
public int getSal() {
return sal;
}

public void setSal(int sal) {
this.sal = sal;
}

public Date getHired() {
return hired;
}

//ToString method prints the name of the class and name of the person
@Override
public String toString() {
return "Employee : " + name;
}

}

class Student extends Person {

//Instance variable
String status;

//This constructor calls super class constructor to set name and email address
public Student(String status, String name, String email) {
super(name, email);
this.status = status;
}

//Getters and setters
public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

//ToString method prints the name of the class and name of the person
@Override
public String toString() {
return "Student : " + name;
}

}

class Faculty extends Employee {

//Instance variable
String officeHrs;

//This constructor calls super class contructor and sets name, salary and email address
public Faculty(String officeHrs, int sal, String name, String email) {
super(sal, name, email);
this.officeHrs = officeHrs;
}

//Getters and setters
public String getOfficeHrs() {
return officeHrs;
}

public void setOfficeHrs(String officeHrs) {
this.officeHrs = officeHrs;
}

//ToString method prints the name of the class and name of the person
@Override
public String toString() {
return "Faculty : " + name;
}

}

class Staff extends Employee {

//Instance variable
String title;

//This constructor calls super class constructor to set salary, name and email address.
public Staff(String title, int sal, String name, String email) {
super(sal, name, email);
this.title = title;
}

//Getters and setters
public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

//ToString method prints the name of the class and name of the person
@Override
public String toString() {
return "Staff : " + name;
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote