Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java files Lab 1 In this lab, create a few classes/objects. Exercises 1. Create a 4 new classes: Company, Employee, Manager, Intern 2. In the

Java files

Lab 1

In this lab, create a few classes/objects.

Exercises

1. Create a 4 new classes: Company, Employee, Manager, Intern

2. In the Intern class, add the following field variables

Note: Data type and name will be part of the points here.

A. A variable to store their full name

B. A variable to store their employee number (mix of letters and numbers)

C. A variable to store their salary

D. A variable to store their Manager.

3. In the Manager class, add the following field variables

Note: Data type and name will be part of the points here.

A. A variable to store their full name

B. A variable to store their employee number (mix of letters and numbers)

C. A variable to store their salary

D. A variable to store a list of Interns.

4. In the Employee class, add the following field variables

Note: Data type and name will be part of the points here.

A. A variable to store their full name

B. A variable to store their employee number (mix of letters and numbers)

C. A variable to store their salary

5. In the Company class, add the following field variables

Note: Data type and name will be part of the points here.

A. A variable to store the company name

B. A variable to store a list of Employees

C. A variable to store a list of Managers

D. A variable to store a list of Interns.

6. Add constructors to all of the classes. They will pass in all non-list data. The list data will just be defaulted to a new list.

7. Add the getter and setter methods for all non-list field variables in all four classes.

8. Add add and remove methods for the list field variables in the two classes with Lists.

9. Add the toString method for each class. The list field variables will require a loop to properly print out the information.

10. In the Company class, create a main method.

11. In the main method, create at least 5 total Employees, Managers and Interns (at least 1 of each type).

12. In the main method, create a Company object

13. Add the objects to their appropriate Lists

14. Output all of the data created to verify toStrings worked.

Lab 2: Refactoring and Inheritance

Summary

In this lab, refactor the code

Use your code from Lab 1

Answer The Questions

Keep your answers to these questions short and to the point. Put your answer in the Company class in the top comment section.

  1. True or False: You can extend more than one class.
  2. True of False: All classes with an abstract method have to be abstract classes.

Exercises

1. Refactor the code to do the following:

A. Intern class will extend the Employee class.

B. Manager class will extend the Employee class.

2. Fix the code in the Intern and Manager class to remove duplicate code.

3. Update the toString methods in the Intern and Manager class to call their super class' toString to reduce duplicate text.

4. In the Company class, refactor the code to have 1 ArrayList of the super class instead of 3 different ArrayLists.

5. Update the add and remove methods in the Company class.

6. Add an additional field to the Employee class. A variable to store their email address.

7. Update all of the constructors based on the previous changes.

8. Update the main method based on the previous changes.

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

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions