The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Create a new “Java Application” project, name it as “InheritanceExample”
In this project, add a new Class call “People”. This class must extends the Object class in java. “People” has following protected attributes: String firstName, String lastName, Date birthday (import java.util.Date), int SSN. To access these 4 protected members, please create 4 public getters and setters for all these protected attributes. For class people, also create two constructors. One constructor take all 4 paramenters, one constructor only takes 2 parameters (firstName, lastName).
In “People” class, create a Display() method. This method will display following information. If this People object has only firstName, lastName, then display “This is firstName lastName”. If this People object has firstName, lastName, birthdate, SSN then display “This is [firstName] [lastName] with SSN#[SSN]”
Add a new subclass call “Student”. This subclass must extends the People superclass in java. “Student” has following protected attributes: String[] courseList, int studentID, int scholarship. For your student subclass, add one new constructor, which will take 3 parameters Student(String firstName, String lastName, int scholarship). Make sure in your constructor, the super constructor of 2 parameters should be called, else you will get compilation error.
Add a new subclass call “Employee”. This subclass must extends the People superclass in java. “Employee” has following protected attributes: int salary, int employeeID. For your Employee subclass, add one new constructor, which will take 6 parameters Employee(String firstName, String lastName, int salary, int employeeID, int SSN, Date birthday). Make sure in your constructor, the super constructor of 4 parameters should be called, else you will get compilation error.
Add a new subclass call “Faculty”. This subclass must extends the Employee superclass in java. “Faculty” has following extra protected attributes: String[] courseList. Faculty must have a constructor that accepts 6 parameters Faculty(String firstName, String lastName, int salary, int employeeID, int SSN, Date birthday).
Add a new subclass call “Staff”. This subclass must extends the Employee superclass in java. “Staff” has following extra protected attributes: String jobDuty. Staff must have a constructor that accepts 6 parameters Staff (String firstName, String lastName, int salary, int employeeID, int SSN, Date birthday).
After you have built a Hierarchy of inherited classes, in you main application, please do following:
Create a new People object, with all 4 parameters
Create a new Student object, with 2 parameters
Create a new Faculty object, with all 6 parameters
Create a new Staff object, with all 6 parameters
Call all previous 4 objects’ Display() function
-----------