Question: Design a class named Employee. Instance variables: Employee name Employee number in the format XXX-L, where each X is a digit within the range 0-9,



Design a class named Employee.

Instance variables:

  • Employee name
  • Employee number in the format XXX-L, where each X is a digit within the range 0-9, and the L is a letter.
  • Hire date

Methods:

  • Constructors: create one constructor that accepts all three instance variables
  • Getters and setters for all three instance variables
  • isValidEmplNum- This method accepts a string variable that represents an employee number. You will return true if it is valid based on criteria stated above and false if not.
  • toString()- Should output the name, employee number and hire date. If the date is blnak, then output INVALID EMPLOYEE NUMBER.


Design a class named ProductionWorker that inherits from Employee

Instance variables:

  • constants- DAY_SHIFT and NIGHT_SHIFT set to 1 and 2 respectively that represent the shift the employee works
  • shift- 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.
  • payrate
  • a daily production container that stores a workers production for any given day of the year. The container consists of an array or arrayList that holds each workers daily production, as an integer. The size will be 365, to represent the total days in a year.
  • A variable that keeps track of the actual size of the array

Methods:

  • Constructors- create one constructor that accepts all values from the Employee class and shift and payrate
  • Getters and setters for only those variables that you actually use (you might want to create these as you need them)
  • toString- This method should output everything from the Employee class, by calling the correct method to do this, as well as the correct shift. It should display "Day" if the shift is a 1 and "Night" if the shift is a 2. IF the shift is not a 1 or a 2, then it should display "INVALID SHIFT NUMBER". It should also display the hourly payrate with labels and correct formatting for currency.I
  • calculateYearlyProduction- This method traverses the array of production and returns a total of all values


Design a class named ShiftSupervisor that inherits from Employee


A shift supervisor is a salaried employee who supervises a shift. In addition to a salary, the shift supervisor earns a yearly bonus when his or her shift meets production goals.


The ShiftSupervisor class should have a field that holds the annual salary, and a field that holds the annual production bonus that a shift supervisor has earned. Write one or more constructors and the appropriate accessor and mutator methods for the class.


Instance variables:

  • constants- DAY_SHIFT and NIGHT_SHIFT set to 1 and 2 respectively that represent the shift the employee works
  • salary
  • bonus
  • shift

Methods:

  • Constructor that accepts the values from Employee class as well as all three instance variables
  • Getters and setters for all three instance variables
  • toString- This method should output everything from the Employee class by calling a method to do this and correctly formatted salary and bonus.


Design a class named TeamLeader that inherits from ProductionWorker

A team leader is an hourly paid production worker who leads a small team. In addition to hourly pay, team leaders earn a fixed monthly bonus. Team leaders are required to attend a minimum number of hours of training per year. Design a TeamLeader class that inherits from the ProductionWorker class. The TeamLeader class should have fields for the annual bonus amount, the required number of training hours, and the number of training hours that the team leader has attended. Write one or more constructors and the appropriate accessor and mutator methods for the class.

Instance Variables:

  • annual bonus amount
  • required training hours
  • attended training hours

Methods:

  • Constructor that accepts the values from ProductionWorker and the three instance variables
  • Getters and setters for all three instance variables
  • toString- This method should call a method to output all ProductionWorker content as well as properly formatted bonus, and the Required Training Hours and Training Hours Attended





Driver class:

Global variables: an employee container and the size of that container

Methods:

  • main
    • Instantiate the container. If you use an array, it must be at least size 20
    • Call all other methods needed and defined below


  • readRecords- This method reads in the employeeRecords. This file is space delimited. The first character represents the type of employee. Once that character is read in, it will need to determine whether it is a 1, 2 or 3.
    • 1 represents a ProductionWorker
      • Name,name,number, date, shift, payrate
    • 2 represents a ShiftSupervisor
      • Name,name,number,date,shift,salary,bonus
    • 3 represents a TeamLeader
      • Name,name,number,date,shift,payrate,annual bonus amount, required hours of training, completed hours of training


  • Your program will then read in the properties of each object from a file and create the appropriate object.
  • The object will then be stored in your container.
  • Note that the objects must be defined correctly and stored in the Employee container.
  • setProduction- This method generates random numbers to be stored in the production containers. You can do this however you choose, but the numbers should fall between 0 and 100.
    • First, you need to ask the user how many days of production you want to load. This can be any number from 1-365. Note that random numbers are designed to average out to about the same numbers, the more numbers you generate, so when you run it, it is better to use small numbers. This will give you the variance in averages that you need to test it. You will return the total number of days.
    • Traverse through your employee list. Check each employee to determine if they are a ProductionWorker (Remember TeamLeaders are also ProductionWorkers. If they are ProductionWorkers then you will need to typecast that specific cell to a ProductionWorker:

ProductionWoker worker = (ProductionWorker) employees[i];

From this point forward within the loop, you would use worker, not employees.

  • Traverse through the production container based on the number of days that the user indicated and load each cell with a random number.
  • calculateAverage- This method accepts the total and the count as parameters for either shift and returns the average.
  • determineSupervisorBonus- This method accepts the total number of days as an argument. It will traverse through the employee container and for all employees that are ProductionWorkers, you will call the calculateYearlyProduction method from the ProductionWorker class and add the result to the shift total. You will need to do this for all of the day shift and another total for all of the night shift.
    • Call the calculateAverage twice, passing the totals and counts for a single shift. Then call it again for the other shift.
    • Traverse the employee container and look for all employees that are ShiftSupervisors and typecast accordingly
    • If the average for day shift is greater than 60 they get the bonus, so print out an appropriate formatted message. Otherwise, the bonus is 0.
    • If the average for the night shift is greater than 50 they get the bonus, so print out an appropriate formatted message. Otherwise, the bonus is 0.
    • Finally, you should output the details for each supervisor
  • determineTeamLeadBonus- This method finds all those employees who are team leads and determines if they are eligible for the bonus. A team leader is eligible for the bonus if they completed the required training hours.
    • Traverse the employee container and locate those employees that are Team Leaders, and properly typecast them.
    • Print a message to indicate whether they have earned a bonus. If they earned a bonus, a properly formatted amount should be displayed
    • Print the details for the leader.
  • printAllProd- This method will print all employees that are production workers. Since TeamLeaders are ProductionWorkers, it is important that you first check if they are a TeamLeader and properly typecast them as a TeamLeader, so that the TeamLeader information is correctly printed out, before then checking if they are a ProductionWorker.



Sample Output

How many days do you want to determine production? (From 1-365)50

Supervisor Rosa Parks earned $1,250.00

Name: Rosa Parks

Employee Number: 012-r

Hire Date: 05/13/2000

Annual Salary: $48,563.50

Production Bonus: $1,250.00


Supervisor Alex Baldwin earned $1,000.00

Name: Alex Baldwin

Employee Number: INVALID EMPLOYEE NUMBER

Hire Date: 09/09/2005

Annual Salary: $46,326.20

Production Bonus: $1,000.00


Bonus not earned.

Name: Betty White

Employee Number: 147-b

Hire Date: 02/28/2001

Shift: Day

Hourly Pay Rate: $22.10

Monthly Bonus: $300.00

Required Training Hours: 20.0

Training Hours Attended: 10.0


Bonus earned $450.00

Name: Ricardo Whitehead

Employee Number: 258-r

Hire Date: 10/22/2009

Shift: Night

Hourly Pay Rate: $20.00

Monthly Bonus: $450.00

Required Training Hours: 25.0

Training Hours Attended: 30.0


All Production Workers

-----------------------------

Name: Susan Smith

Employee Number: 456-s

Hire Date: 01/24/2010

Shift: Day

Hourly Pay Rate: $22.80


Name: Beth Simpson

Employee Number: 234-b

Hire Date: 04/14/2014

Shift: Day

Hourly Pay Rate: $24.50


Name: Nate Bartlett

Employee Number: 345-n

Hire Date: 09/23/2018

Shift: Night

Hourly Pay Rate: $19.50


Name: Oswald Benet

Employee Number: 567-o

Hire Date: 04/18/2016

Shift: Night

Hourly Pay Rate: $18.30


Name: Javed Mahari

Employee Number: 678-j

Hire Date: 05/14/2020

Shift: Day

Hourly Pay Rate: $16.20


Name: Betty White

Employee Number: 147-b

Hire Date: 02/28/2001

Shift: Day

Hourly Pay Rate: $22.10

Monthly Bonus: $300.00

Required Training Hours: 20.0

Training Hours Attended: 10.0


Name: Judy Summers

Employee Number: 789-j

Hire Date: 08/09/2015

Shift: Day

Hourly Pay Rate: $18.90


Name: Adam Gentile

Employee Number: 890-a

Hire Date: 0703/2008

Shift: Night

Hourly Pay Rate: $24.20


Name: Xavier Gonzales

Employee Number: 901-x

Hire Date: 11/20/2019

Shift: Night

Hourly Pay Rate: $16.30


Name: Ricardo Whitehead

Employee Number: 258-r

Hire Date: 10/22/2009

Shift: Night

Hourly Pay Rate: $20.00

Monthly Bonus: $450.00

Required Training Hours: 25.0

Training Hours Attended: 30.0


Name: Brandon Carter

Employee Number: 345-b

Hire Date: 11/01/2020

Shift: Day

Hourly Pay Rate: $17.30


Name: Joe Evans

Employee Number: 456-j

Hire Date: 01/01/2010

Shift: Day

Hourly Pay Rate: $20.20



****************A second run****************************

How many days do you want to determine production? (From 1-365)25

Supervisor Rosa Parks earned $0

Name: Rosa Parks

Employee Number: 012-r

Hire Date: 05/13/2000

Annual Salary: $48,563.50

Production Bonus: $1,250.00


Supervisor Alex Baldwin earned $1,000.00

Name: Alex Baldwin

Employee Number: INVALID EMPLOYEE NUMBER

Hire Date: 09/09/2005

Annual Salary: $46,326.20

Production Bonus: $1,000.00


Bonus not earned.

Name: Betty White

Employee Number: 147-b

Hire Date: 02/28/2001

Shift: Day

Hourly Pay Rate: $22.10

Annual Bonus: $300.00

Required Training Hours: 20.0

Training Hours Attended: 10.0


Bonus earned $450.00

Name: Ricardo Whitehead

Employee Number: 258-r

Hire Date: 10/22/2009

Shift: Night

Hourly Pay Rate: $20.00

Annual Bonus: $450.00

Required Training Hours: 25.0

Training Hours Attended: 30.0


All Production Workers

-----------------------------

Name: Susan Smith

Employee Number: 456-s

Hire Date: 01/24/2010

Shift: Day

Hourly Pay Rate: $22.80


Name: Beth Simpson

Employee Number: 234-b

Hire Date: 04/14/2014

Shift: Day

Hourly Pay Rate: $24.50


Name: Nate Bartlett

Employee Number: 345-n

Hire Date: 09/23/2018

Shift: Night

Hourly Pay Rate: $19.50


Name: Oswald Benet

Employee Number: 567-o

Hire Date: 04/18/2016

Shift: Night

Hourly Pay Rate: $18.30


Name: Javed Mahari

Employee Number: 678-j

Hire Date: 05/14/2020

Shift: Day

Hourly Pay Rate: $16.20


Name: Betty White

Employee Number: 147-b

Hire Date: 02/28/2001

Shift: Day

Hourly Pay Rate: $22.10

Annual Bonus: $300.00

Required Training Hours: 20.0

Training Hours Attended: 10.0


Name: Judy Summers

Employee Number: 789-j

Hire Date: 08/09/2015

Shift: Day

Hourly Pay Rate: $18.90


Name: Adam Gentile

Employee Number: 890-a

Hire Date: 0703/2008

Shift: Night

Hourly Pay Rate: $24.20


Name: Xavier Gonzales

Employee Number: 901-x

Hire Date: 11/20/2019

Shift: Night

Hourly Pay Rate: $16.30


Name: Ricardo Whitehead

Employee Number: 258-r

Hire Date: 10/22/2009

Shift: Night

Hourly Pay Rate: $20.00

Annual Bonus: $450.00

Required Training Hours: 25.0

Training Hours Attended: 30.0


Name: Brandon Carter

Employee Number: 345-b

Hire Date: 11/01/2020

Shift: Day

Hourly Pay Rate: $17.30


Name: Joe Evans

Employee Number: 456-j

Hire Date: 01/01/2010

Shift: Day

Hourly Pay Rate: $20.20



Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

accomplish this task well create several classes in Java according to the provided specifications Lets start by defining the Employee class import javautilregex public class Employee private String na... View full answer

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 Programming Questions!