Design a class named Employee. The class should keep the following information in fields:
The Employee and Productionworker Classes Problem
Employee name
Employee number in the format XXX-L, where each X is a digit within the range 09 and the L is a letter within the range AM.
Hire date
Write one or more constructors and the appropriate accessor and mutator methods for the class.
Next, write a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information:
Shift (an integer)
Hourly pay rate (a double)
The workday is divided into two shifts: day and night. The shift field will be an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2. Write one or more constructors and the appropriate accessor and mutator methods for the class. Demonstrate the classes by writing a program that uses a ProductionWorker object.
Notes:
For John Smith, call constructor passing all values (3 for employee class and 2 for ProductionWorker class)
For Joan Jones, call setters to set values
Employee number should meet the format listed in the problem. If employee number does not meet the format, display it as listed below: Employee Number: INVALID EMPLOYEE NUMBER
Create toString methods in both Employee and ProductionWorker classes so that you can pass the objects to println method and it should display the content of each object as shown in the output below.
It is advised to create the Employee number validation in Employee class so that when setEmployeeNumber method is called or Employee constructor is called , validation method will be called to validate the Employee number.
The output should similar to the following:
Here's the first production worker. Name: John Smith Employee Number: 123-A Hire Date: 11-15-2005 Shift: Day Hourly Pay Rate: $16.50
Here’s the second production worker. Name: Joan Jones Employee Number: 222-L Hire Date: 12-12-2005 Shift: Night Hourly Pay Rate: $18.50
The Employee Number is invalid for John Smith:
Here's the first production worker. Name: John Smith Employee Number: INVALID EMPLOYEE NUMBER Hire Date: 11-15-2005 Shift: Day Hourly Pay Rate: $16.50
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.