Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Join the following Java classes into a hierarchy. If the sub classes are shown on the same level, then they share a parent class. If

Join the following Java classes into a hierarchy. If the sub classes are shown on the same level, then they share a parent class. If the parent class has the same attributes as the sub class then remove those attributes from the subclass. The superclass should only contain attributes or functionality that are contained in all subclasses.

Person - Super Class
Staff - Subclass Faculty - Subclass Student - Subclass | Super Class
UndergraduateStudent - Subclass GraduateStudent - Subclass

Staff:

public class Staff { private String FirstName; private String LastName; private String Department; private String Title; private int UIN; public Staff() { this.FirstName = ""; this.LastName = ""; this.Department = ""; this.Title = ""; this.UIN = 0; } public Staff(String FirstName, String LastName, String Department, String Title, int UIN) { this.FirstName = FirstName; this.LastName = LastName; this.Department = Department; this.Title = Title; this.UIN = UIN; } public void setFirstName(String FirstName) { this.FirstName = FirstName; } public String getFirstName() { return this.FirstName; } public void setLastName(String LastName) { this.LastName = LastName; } public String getLastName() { return this.LastName; } public void setDepartment(String Department) { this.Department = Department; } public String getDepartment() { return this.Department; } public void setTitle(String Title) { this.Title = Title; } public String getTitle() { return this.Title; } public void setUIN(int UIN) { this.UIN = UIN; } public int getUIN() { return this.UIN; } @Override public String toString() { return "FirstName: " + this.FirstName + ", LastName: " + this.LastName + ", Department: " + this.Department + "Title: " + this.Title + ", UIN: " + this.UIN; } }

Faculty:

public class Faculty { private String firstName; private String lastName; private int department; private int UIN; public Faculty() { } public Faculty(String firstName, String lastName, int department, int UIN) { this.firstName = firstName; this.lastName = lastName; this.department = department; this.UIN = UIN; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public int getDepartment() { return department; } public void setDepartment(int department) { this.department = department; } public int getUIN() { return UIN; } public void setUIN(int uin) { this.UIN = uin; } public String toString() { return "Faculty [firstName=" + firstName + ", lastName=" + lastName + ", department=" + department + ", UIN=" + UIN + "]"; } } 

Student:

public class Student { private String FirstName; private String LastName; private String Major; private String Minor; private Integer UIN; private Double GPA; public Student() { } public Student(String FirstName, String LastName, String Major, String Minor, Integer UIN, Double GPA) { this.FirstName = FirstName; this.LastName = LastName; this.Major = Major; this.Minor = Minor; this.UIN = UIN; this.GPA = GPA; } public String getFirstName() { return FirstName; } public void setFirstName(String student_firstName) { FirstName = student_firstName; } public String getLastName() { return LastName; } public void setLastName(String student_lastName) { LastName = student_lastName; } public String getMajor() { return Major; } public void setMajor(String student_major) { Major = student_major; } public String getMinor() { return Minor; } public void setMinor(String student_minor) { Minor = student_minor; } public Integer getUIN() { return UIN; } public void setUIN(Integer student_UIN) { UIN = student_UIN; } public Double getGPA() { return GPA; } public void setGPA(Double student_GPA) { GPA = student_GPA; } @Override public String toString() { return "Student : FirstName=" + FirstName + ", LastName=" + LastName + ", Major=" + Major + ", Minor=" + Minor + ", UIN=" + UIN + ", GPA=" + GPA + "]"; } }

Undergraduate Student:

public class UndergraduateStudent { private String FirstName; private String LastName; private String Major; private String Minor; private Integer UIN; private Double GPA; public UndergraduateStudent() { } public UndergraduateStudent(String aFirstName, String aLastName, String aMajor, String aMinor, Integer aUIN, Double aGPA) { super(); FirstName = aFirstName; LastName = aLastName; Major = aMajor; Minor = aMinor; UIN = aUIN; GPA = aGPA; } double calculateFinalGrade(Double a, Double b, Double c) { return (a + b + c) / 3; } public String getFirstName() { return FirstName; } public String getLastName() { return LastName; } public String getMajor() { return Major; } public String getMinor() { return Minor; } public Integer getUIN() { return UIN; } public Double getGPA() { return GPA; } public void setFirstName(String aFirstName) { FirstName = aFirstName; } public void setLastName(String aLastName) { LastName = aLastName; } public void setMajor(String aMajor) { Major = aMajor; } public void setMinor(String aMinor) { Minor = aMinor; } public void setUIN(Integer aUIN) { UIN = aUIN; } public void setGPA(Double aGPA) { GPA = aGPA; } public String toString() { return "UndergraduateStudent [FirstName=" + FirstName + ", LastName=" + LastName + ", Major=" + Major + ", Minor" + Minor + ", GPA=" + GPA + ", UIN=" + UIN + " "; } } 

Graduate Student:

public class GraduateStudent { private String FirstName; private String LastName; private String Major; private String Minor; private Integer UIN; private Double GPA; public GraduateStudent() { } public GraduateStudent(String aFirstName, String aLastName, String aMajor, String aMinor, Integer aUIN, Double aGPA) { super(); FirstName = aFirstName; LastName = aLastName; Major = aMajor; Minor = aMinor; UIN = aUIN; GPA = aGPA; } double calculateFinalGrade(Double a, Double b, Double c) { return (a + b + c) / 3; } public String getFirstName() { return FirstName; } public String getLastName() { return LastName; } public String getMajor() { return Major; } public String getMinor() { return Minor; } public Integer getUIN() { return UIN; } public Double getGPA() { return GPA; } public void setFirstName(String aFirstName) { FirstName = aFirstName; } public void setLastName(String aLastName) { LastName = aLastName; } public void setMajor(String aMajor) { Major = aMajor; } public void setMinor(String aMinor) { Minor = aMinor; } public void setUIN(Integer aUIN) { UIN = aUIN; } public void setGPA(Double aGPA) { GPA = aGPA; } public String toString() { return "GraduateStudent [FirstName=" + FirstName + ", LastName=" + LastName + ", Major=" + Major + ", Minor" + Minor + ", GPA=" + GPA + ", UIN=" + UIN + " "; } } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions