I'm working on the following program.
Design a class named Employee. The class should keep the following information in fields:
a. Employee name. b. Employee number in the format XXX-L, where each X is a digit within the range 0-9 and the L is a letter within the range A-M. c. 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:
a. Shift (an integer). b. 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.
In a particular factory, 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. Design a ShiftSupervisor class that extends the Employee class. 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. Demonstrate the classes by writing a program that uses ProductionWorker and ShiftSupervisor objects.
import java.time.Instant;
import java.util.Date;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ShiftSupervisor supervisor = new ShiftSupervisor();
ProductionWorker worker = new ProductionWorker();
System.out.println("Workers Management System");
System.out.println("Create Supervisors");
//Prompts
System.out.println("Enter supervisor name");
String sName = sc.nextLine();
System.out.println("Enter employee number [Patters XXX-L]");
String eNumber = sc.nextLine();
//Setters
supervisor.setsName(sName);
supervisor.seteNumber(eNumber);
System.out.println("Supervisor in company: " + supervisor.getsName() + " Number: " +
supervisor.geteNumber());
System.out.println("Set " + supervisor.getsName()+ " annual fee");
double annualFee = sc.nextDouble();
supervisor.setAnnualSalary(annualFee);
System.out.println("Set " + supervisor.geteName() + " production bonus: ");
double annualProductionBonus = sc.nextDouble();
supervisor.setAnnualProductionBonus(annualProductionBonus);
//Prompts
System.out.println("Enter worker name: ");
String eName = sc.nextLine();
worker.seteName(eName);
System.out.println("Enter production worker number [Patters XXX-L]");
String eWNumber = sc.nextLine();
//Setters
worker.seteNumber(eWNumber);
System.out.println("Production worker in company: " + worker.geteName() + " Number: " +
worker.geteNumber());
System.out.println("Set " + worker.geteName() + " shift [0 or 1] is allowed");
int shiftNumber = sc.nextInt();
worker.setShift(shiftNumber);
System.out.println("Set " + worker.geteName() + " hourly pay rate");
double payRate = sc.nextDouble();
worker.setHourRate(payRate);
System.out.println("Supervisor: " + supervisor.geteName() + " " + supervisor.geteNumber() + " Annual
Salary : " + supervisor.getAnnualSalary() + " Production Bonus: " +
supervisor.getAnnualProductionBonus());
System.out.println("Production Worker: " + worker.geteName() + " " + worker.geteNumber() + "
HourlyRate : " + worker.getHourRate() + " Shift: " + worker.getShift());
}
}
// NEW CLASS
ProductionWorker class
enum Shift {
Day,
Night
}
public class ProductionWorker extends Employee {
private Shift shift;
private double hourRate;
//Getters
public double getHourRate() {
return hourRate;
}
public Shift getShift() {
return shift;
}
//Setters
public void setHourRate(double hourRate) {
this.hourRate = hourRate;
}
public void setShift(int shift) {
if (shift ==1 ) {
this.shift = Shift.Day;
} else if (shift == 2) {
this.shift = Shift.Night;
}
}
}
// New Class
The employee class
import java.util.Date;
public class Employee {
private String eName;
private String sName;
private String eNumber;
private Date hireDate;
public Employee(){};
public Employee(String eName, String sName, String eNumber, Date hireDate){
this.eName = eName;
this.sName = sName;
this.eNumber = eNumber;
this.hireDate = hireDate;
};
//Getters
public Date getHireDate() {
return hireDate;
}
public String geteName() {
return eName;
}
public String getsName() {
return sName;
}
public String geteNumber() {
return eNumber;
}
//Setters
public void seteName(String eName) {
this.eName = eName;
}
public void setsName(String sName) {
this.sName = sName;
}
public void seteNumber(String eNumber) {
this.eNumber = eNumber;
}
public void setHireDate(Date hireDate) {
this.hireDate = hireDate;
}
}