Question: Write an Employee class that has the following fields. This class should be defined as a separate file within your Java Project. Points will be

Write an Employee class that has the following fields. This class should be defined as a separate file within your Java Project. Points will be deducted if the class is embedded as an inner class. This does not affect the name of your Java Project above.

empName: a String object that holds the employee's name.

empID: an integer that holds the employee's ID number.

timeIn: a Clock object. Note this class was developed in the previous assignment. Methods may be added to this class to increase its functionality as needed.

timeOut: a Clock object. Note this class was developed in the previous assignment. Methods may be added to this class to increase its functionality as needed.

The class should have the following methods:

Constructor: a no-arg constructor that assigns the empty string (" ") to the empName, 0 to the empID, and 00:00:00 to the timeIn and timeOut fields.

Constructor: accepts values specified by the user for each field as an argument.

hoursWorked: returns the amount of time an employee has worked on a given day in the format hh:mm. An hour should be allotted for lunch, if at least six hours are documented. Do not include lunch time in the total hours worked.

reverseOrder: returns the elements of the ArrayList of Employee objects in reverse order without creating a new ArrayList. You may only use the methods remove, add, and size.

Write appropriate mutator and accessor methods for all fields.

Demonstrate the class in a complete program that prompts the user to input a list of employees' names, IDs, timeIn, and timeOut. This list of Employee objects must be stored in an ArrayList. It should then display the data for each employee on the screen, along with their hours worked. Next, display the list in reverse order.

A sample display is below. These values should NOT be hardcoded into your program. Note: The table lines are not required in your output.

Name ID Number Time In Time Out Hours Worked
Susan Meyers 47899 8:00:00 17:00:00 8:00
Mark Jones 39119 7:30:05 16:35:10 8:05
Joy Rogers 81774 11:15:21 16:15:01 5:00

Please note that you MUST use an ArrayList, as opposed to normal arrays. The timeIn and timeOut values MUST be entered as military time.

Input Validation: Do not accept unreasonable time, junk values, or negative values, which must be rejected and asked for another one.

Also, be sure that clear instructions are given to the user.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!