Inheritance   Create a class named Person and its two subclasses named Student and Employee.  Then create Faculty and Staff as subclasses of Employee.     A Person has a name, address, phone number, and email address.  Each of these will be String objects. A Student has a class status which will be an int ( 1 for a freshman, 2 for a sophomore, 3 for a junior, or 4 for a senior). An Employee has an office (String), salary(int), and a date hired(String).   A Faculty Member has office hours (String) and a rank which will be an int(1 for a Lecturer, 2 for an Assistant Professor, 3 for an Associate Professor, or 4 for a Professor). A Staff member has a title.     Each class will have a toString() method to display the name of the class and the person’s name.  For a Student, the toString() method will also return the class status (freshman, sophomore, junior, senior), for an Employee, the salary, for a faculty member, the rank (Lecturer, Assistant Professor, Associate Professor, Professor), and for a Staff member, the title.   Make sure that the code in all classes in your Person inheritance hierarchy is thoroughly documented.  Show how each class relates to any other class in the hierarchy.  All methods must have comments.   Write a test class named InheritanceDemo that  Creates a Person, Student, Employee, Faculty Member, and a Staff Member. Sets values for all properties for a particular object (e.g. for a Student you will give the student a name, address, phone number, email address, and class status).  Prints a string representation for each object, i.e invoke their toString() method.   Notes: Give all instance variables protected visibility to allow access without setters and getters Use an appropriate constructor for all classes.  Make sure that each constructor assigns values for all instance variables of the particular class.  You may want to view the videos again, taking note of how the properties for each object get their values. Hard code the data in InheritanceDemo class.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

1.  Inheritance

 

Create a class named Person and its two subclasses named Student and Employee.  Then create Faculty and Staff as subclasses of Employee.  

 

  • A Person has a name, address, phone number, and email address.  Each of these will be String objects.
  • A Student has a class status which will be an int ( 1 for a freshman, 2 for a sophomore, 3 for a junior, or 4 for a senior).
  • An Employee has an office (String), salary(int), and a date hired(String).  
  • A Faculty Member has office hours (String) and a rank which will be an int(1 for a Lecturer, 2 for an Assistant Professor, 3 for an Associate Professor, or 4 for a Professor).
  • A Staff member has a title.  

 

Each class will have a toString() method to display the name of the class and the person’s name.  For a Student, the toString() method will also return the class status (freshman, sophomore, junior, senior), for an Employee, the salary, for a faculty member, the rank (Lecturer, Assistant Professor, Associate Professor, Professor), and for a Staff member, the title.

 

Make sure that the code in all classes in your Person inheritance hierarchy is thoroughly documented.  Show how each class relates to any other class in the hierarchy.  All methods must have comments.

 

Write a test class named InheritanceDemo that 

  • Creates a Person, Student, Employee, Faculty Member, and a Staff Member.
  • Sets values for all properties for a particular object (e.g. for a Student you will give the student a name, address, phone number, email address, and class status).  Prints a string representation for each object, i.e invoke their toString() method.

 

Notes:

  • Give all instance variables protected visibility to allow access without setters and getters
  • Use an appropriate constructor for all classes.  Make sure that each constructor assigns values for all instance variables of the particular class.  You may want to view the videos again, taking note of how the properties for each object get their values.
  • Hard code the data in InheritanceDemo class.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education