Problem: (The Person, Sruden, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, date hired. Define a class named MyDate that contains the fields year, month, and day. A faculty member has office hours and a rank. A staff member has a title. Overridde the toString method in each class to display the class name and the person's name.
Draw the UML diagram for classes. Implement the classes. Write a tes program that creates a Person, Student, Employee, Faculty, and Staff, and invokes their toString() methods
I am having trouble overriding the toString method in each class, Can any one give me any clarfication? (And If you see any other problems i might have, please help, thanks) And am I using the Superclass correctly?
public class Person { private String name, address, phone, email; public Person(){ } public Person(String name, String address, String phone, String email){ this.name = name; this.address = address; this.phone = phone; this.email = email; } public String getName(){ return name; } public void setName(String name){ this.name = name; } public String getAddress(){ return address; } public void setAddress(String address){ this.address = address; } public String getPhone(){ return phone; } public void setPhone(String phone){ this.phone = phone; } public String getEmail(){ return phone; } public void setEmail(String email){ this.email = email; } @Override public String toString(){ return getClass().getName() + "\n" + name; } }
public class Student extends Person{ private final String CLASS_STATUS; public Student(String name, String address, String phone, String email,String CLASS_STATUS){ super(name, address, phone, email); this.CLASS_STATUS =CLASS_STATUS; } public String getClassStatus(){ return CLASS_STATUS; } }