Question
ABSTRACTION, INHERITANCE AND COMPOSITION Create an abstract base class Person. Person object will have the following member fields. Name Id Address Since the address a
ABSTRACTION, INHERITANCE AND COMPOSITION
Create an abstract base class Person. Person object will have the following member fields.
Name
Id
Address
Since the address a more complex entity it will be defined by Address class. Here are the field necessary to define an address.
Street
City
Zip code
Country (country will have a default value USA)
The usage of the Address class in the Person class is form of composition.
Extending the abstract Person class we will create two concrete class (non-abstract).
Employee class
Student class
Employee class will have additional fields: salary and social security number. For security reason when we perform get on SSN it will only return the last 4 digits in the following format ##-##-1234.
Student class will have additional fields: gpa and number of credits completed
To test and the above created class we will create an application class (only class with public void main(String [] args) method). The application class should create 5 instances of Employee and 20 instances of Student class. Use data structure such as List<> or [] (array) to store the instances. For
example, List employees = new ArrayLists<>();
Print (System.out.println) the name and salary of all the Employees. Similarly print the name, address, and gpa of all created students.
HINT: may what to override the to string of Address to make it easy to print. Guidelines
All class should allow initialization of objects via constructor parameter.
All member fields should have the necessary accessor and mutator (i.e. getters and setters)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started