Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a class named Employee. The class should keep the following information i

ID: 3777344 • Letter: D

Question

Design a class named Employee. The class should keep the following information in fields: 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 within the range A-M. Hire date Write one or more constructors and the appropriate accessor and mutator methods foe 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 mutator for the class. Demonstrate the classes by writing a program that uses a Production object. In a particular factory, a shift supervisor is a salaried employee who supervises 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 you created in Programming Challenge 1. 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 accessors and mutator methods for the class. Demonstrate the class by writing a program that uses a ShiftSupervisor object.

Explanation / Answer

import java.util.*;
import java.lang.*;
import java.io.*;

class Employee
{
   private String EmployeeName;
   private String EmployeeNumber;
   private String HireDate;
  
   public Employee(String EmployeeName,String EmployeeNumber,String HireDate) //constructor
   {
       this.EmployeeName = EmployeeName;
       this.EmployeeNumber = EmployeeNumber;
       this.HireDate = HireDate;
   }
   public void setEmployeeName(String EmployeeName) //set and get methods
   {
       this.EmployeeName = EmployeeName;
   }
   public void setEmployeeNumber(String EmployeeNumber)
   {
       this.EmployeeNumber = EmployeeNumber;
   }
   public void setHireDate(String HireDate)
   {
       this.HireDate = HireDate;
   }
   String getEmployeeName()
   {
       return EmployeeName;
   }
   String getEmployeeNumber()
   {
       return EmployeeNumber;
   }
   String getHireDate()
   {
       return HireDate;
   }
   public String toString() //override toString()
   {
       return "Employee Name :"+getEmployeeName()+" Employee Number : "+getEmployeeNumber()+" Hire Date : "+getHireDate();
   }
}

class ShiftSupervisor extends Employee
{
   private double AnnualSalary;
   private double AnnualBonus;
  
   public ShiftSupervisor(String EmployeeName,String EmployeeNumber,String HireDate,double AnnualSalary,double AnnualBonus)
   {
       super(EmployeeName,EmployeeNumber,HireDate); // call to base class constructor
       this.AnnualSalary = AnnualSalary;
       this.AnnualBonus = AnnualBonus;
   }
   public void setAnnualSalary(double AnnualSalary) //set and get methods
   {
       this.AnnualSalary = AnnualSalary;
   }
   public void setAnnualBonus(double AnnualBonus)
   {
       this.AnnualBonus = AnnualBonus;
   }
   public double getAnnualSalary()
   {
       return AnnualSalary;
   }
   public double getAnnualBonus()
   {
       return AnnualBonus;
   }
   public String toString()
   {
       System.out.println(super.toString()); //call base class toString() method
       return "Annual Salary : "+getAnnualSalary() +" Annual Bonus : "+getAnnualBonus();
   }
}
class TestEmployee
{
   public static void main (String[] args)
   {
       ShiftSupervisor ssv = new ShiftSupervisor("John Smith","101-B","06/24/20015",40000,5000);
      
       System.out.println("Employee Details");
       System.out.println(ssv.toString());
   }
}

output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote