question archive Draw an inheritance hierarchy for students at a university similar to the hierarchy shown in Fig
Subject:Computer SciencePrice:4.89 Bought3
Draw an inheritance hierarchy for students at a university similar to the hierarchy shown in Fig. 9.2. Use Student as the superclass of the hierarchy then extend Student with classes Undergraduate Student and Graduate Student. Continue to extend the hierarchy as deep (i.e., as many levels) as possible. For example, freshman, sophomore, Junior and Senior might extend Undergraduate Student, and Doctoral Student and Masters Student might be subclasses of Graduate Student.
After drawing the hierarchy, discuss the relationships that exist between the classes.
class Student
{
StudentID
Name
DOB
Student(studid,nm,bdate) {}
// accessor methods
}
// class UndergraduateStudent and GraduateStudent inherits Student
class UndergraduateStudent extends Student
{
}
class GraduateStudent extends Student
{
}
// classes that inherits UndergraduateStudent class
class Freshman extends UndergraduateStudent
{
YearofPassing
Grade
Institution
// getter and setter methods
}
class Sophomore extends UndergraduateStudent
{
}
class Junior extends UndergraduateStudent
{
YearofPassing
Grade
Institution
Subjectstaken
// getter and setter methods
}
class Senior extends UndergraduateStudent
{
YearofPassing
Grade
Institution
Subjectstaken
// getter and setter methods
}
// classes that inherits GraduateStudent
class MastersStudent extends GraduateStudent
{
YearofPassing
Grade
Institution
SubjectofSpecialization
// getter and setter methods
}
class DoctoralStudent extends GraduateStudent
{
SubjectofSpecialization
GuidingProfessor
// getter and setter methods
}
The class Student will have some basic member variables and methods. The member variables may include details like StudentID, Name etc which will private variables. The methods may include constructor with parameters like ID and name and the accessor methods which will have public access mode.
The inheriting classes like UndergraduateStudent and GraduateStudent may have further details. The inheriting classes of these classes UndergraduateStudent and GraduateStudent like FreshMan.Sophomore,Masters etc will have details like YearofPassing, Grade, Istitutiion etc. The main link between all the classes and its parent classes will be the StudentID.