Composition and Class Interfaces/Abstract Class
Lab Steps
STEP 1: Understand the UML Diagram
The only change to the Employee class is that there is a new attribute:
+benefit : Benefit
Notice that there is a “+” for this attribute, meaning that it is public. Make sure to examine the multi-arg constructor’s signature!
Also, the dotted directed line between Employee and iEmployee specifies that the Employee class must implement the iEmployee abstract class, and thus provide an implementation for the calculatePay method.
STEP 2: Create the Project
You will want to use the Week 3 project as the starting point for the lab. To do this, you will want to create a new project by following these steps:
STEP 3: Modify the Employee Class
STEP 4: Modify the Main Method
Notice that the Employee class now has a public benefit object inside it. This means that you can access the set methods of the Benefit object with the following code:
<Employee object>.benefit.<method>
As an example, to set the lifeInsurance attribute inside an Employee object called emp, we could execute the following code:
emp.benefit.setLifeInsurance(lifeInsurance);
The steps required to modify the Main class are below. New steps are in bold.
STEP 5: Compile and Test
When done, compile and run your code.
Then, debug any errors until your code is error-free.
Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.
STEP 6: Screen Prints
Capture the Console output window and paste it into a Word document. The following is a sample screen print.
STEP 7: Submit Deliverables
Select your paper details and see how much our professional writing services will cost.
Our custom human-written papers from top essay writers are always free from plagiarism.
Your data and payment info stay secured every time you get our help from an essay writer.
Your money is safe with us. If your plans change, you can get it sent back to your card.
We offer more than just hand-crafted papers customized for you. Here are more of our greatest perks.
Get instant answers to the questions that students ask most often.
See full FAQ