205k views
1 vote
For this lab you will modify your class from Lab 6. Add the following attributes/methods to your

worker class.
Your submission should include a class file and a separate driver file that tests every method.
The worker should have the following new attributes/methods:
a. Hourly salary
b. Overtime hourly salary
c. set_hourly_salary()
d. Sets the worker's hourly salary.
e. If the salary given is less than zero, return false, else, return true
f. set overtime_salary()
g. Sets the worker's overtime salary.
If the salary given is less than zero, return false, else, return true
h. get_hourly salary()
g. Returns the worker's hourly salary
h. get_overtime_pay()
i. Returns the worker's overtime salary
k. get_pay()
l. Returns the workers total pay
o Pay is: (hours_worked hourly_salary) + (overtime overtime_salary)
Be sure to include in your screenshots:
An hourly worker with no overtime
An hourly worker with overtime

User Vivek Ayer
by
7.9k points

1 Answer

5 votes

Final answer:

The student needs to modify their Java worker class to include new attributes and methods for hourly and overtime salaries, and implement methods to set and get these salaries. The worker's total pay should also be calculated based on the hours worked, overtime hours, and salaries. A class file and driver file should be provided for testing purposes.

Step-by-step explanation:

The question is about modifying a class in Java, specifically the 'worker' class from a previous lab. The student is asked to add new attributes and methods to the worker class, including hourly salary, overtime hourly salary, and methods for setting and getting these salaries. The 'get_pay()' method should return the total pay of the worker, which is calculated based on the hours worked, hourly salary, overtime hours, and overtime salary. The student should provide a class file and a driver file to test every method.

User JiteshW
by
7.8k points