Suppose you were given the job to write a Java class to manage employee payroll information in an HR management system. Each employee will be modeled as a single EmployeePayroll object (much like the...

Suppose you were given the job to write a Java class to manage employee payroll information in an HR management system. Each employee will be modeled as a single EmployeePayroll object (much like the Student objects discussed in class). The state of the EmployeePayroll object includes the first name and last name of the employee, a unique 15 digit employee number for each employee, a number of hours that they've worked this week (which could be a fraction of an hour), and the wages per hour the employee earns (measured in dollars and cents). Hours worked and wages per hour are never allowed to fall below zero, and the class should enforce this behavior. The behavior of the EmployeePayroll object is that any of the above member variables can be accessed (so accessor methods need to be written for them). First name, last name and Employee ID can only be set in a constructor method - there should be no mutators given for these fields, and a special constructor should be written to set these values on initialization. The wages per hour field should have a mutator method (but keep in mind that wages cannot be allowed to be set to less than $0.0). In addition to the above, the class should provide three different ways to change the number of hours worked - on that merely sets the hours as a mutator, one that adds to the hours already in place for the employee, and one that resets the employee's hours to zero. Given the above capabilities of the employee payroll record and the skeleton below, write a Java class that can store an employee payroll record. public class EmployeePayroll { // private variables go here public EmployeePayroll( /* Parameters go here*/ ) { // Fill in the constructor. Default for hours and wages is 0 } // write accessors as described above // write mutators as described above public void incrementHours(/*Parameters go here*/) { // Fill in the method. This method should take a number of hours worked // as an argument and increment the total hours by that amount. } public void resetPayCycle(/* Parameters go here*/) { // Fill in the method. This method should reset the variables to start a new week } } Override the methods toString() and equals() inherited from Object for this EmployeePayroll class. The toString() method should return the employee's name, ID, and current calculated pay (wages * hours) as a String. The equals() method should return true if two EmployeePayroll objects have the same employee ids, regardless of name, wages or hours. Write a short test program that tests the EmployeePayroll class you implemented above. Your short program should create a few new EmployeePayroll objects and test a variety of conditions, including a number that your class should not allow (such as setting a negative hourly wage).
Nov 25, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here