Answer to Question #222643 in Java | JSP | JSF for Naveed

Question #222643
Create the following classes (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Design two more classes; Faculty and Staff and extend them from Employee. The detail of classes is as under: 1). A person has a name, address, phone number, and email address. 2). A student has a status (String). 3). An employee has an office, salary, and date hired. Use the Date class to create an object for date hired. 4). A faculty member has office hours and a rank. 5). A staff member has a title. 6). Create display method in each class.
1
Expert's answer
2021-08-02T15:55:41-0400
public ​class PersonDemo {
	public static void main(String args[]) {
		Person person = new Person("Daniel Dyson"), student = new Student("Charles Evans"),
				employee = new Employee("Ethan Carter"), faculty = new Faculty("Harold Brooks"),
				staff = new Staff("Connor Stevenson"), people[] = { person, student, employee, faculty, staff };
		for (Person p : people)
			System.out.println(p);
	}




static ​class Person {
	String name, address, phoneNumber, email;


	Person(String n) {
		name = n;
	}


	@Override
	public String toString() {
		return "Person " + name;
	}
}


static ​class Student extends Person {
	Student(String n) {
		super(n);
	}


	enum Status {
		freshman, sophomore, junior, senior
	}


	Status classStatus;


	@Override
	public String toString() {
		return "Student " + name;
	}


}


static ​class Employee extends Person {
	Employee(String n) {
		super(n);
	}


	String office, hireDate;
	double salary;


	@Override
	public String toString() {
		return "Employee " + name;
	}
}


static ​class Faculty extends Employee {
	Faculty(String n) {
		super(n);
	}


	String officeHours, rank;


	@Override
	public String toString() {
		return "Faculty " + name;
	}
}


static ​class Staff extends Employee {
	Staff(String n) {
		super(n);
	}


	String title;


	@Override
	public String toString() {
		return "Staff " + name;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS