In: Computer Science
JAVA PROGRAMING
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 yearl bonus when his or her
shift meets production goals.Design a ShiftSupervisor
class that extends the Employee class. TheShiftSupervisor 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
constructor
and the appropriate accessor and mutator methods for the
class.Demonstrate
the class by writing a program that uses a ShiftSupervisor
object.
Hi, Please find my implementation of required classes.
Please let me know in case of any issue.
################# Employee.java ##############
public class Employee
{
// fields
private String Empname;
private String Empnumber;
private String Hiredate;
// contructor
public Employee(String Empname,String Empnumber,String
Hiredate)
{
setName (Empname);
setNumber (Empnumber);
setHireDate (Hiredate);
}
//accessor
public String getName()
{
return Empname;
}
public String getNumber()
{
return Empnumber;
}
public String getHireDate()
{
return Hiredate;
}
// mutator
public void setName(String n)
{
Empname = n;
}
public void setNumber(String num)
{
Empnumber = num;
}
public void setHireDate(String h)
{
Hiredate = h;
}
}
################# ShiftSupervisor.java ##############
public class ShiftSupervisor extends Employee
{
//fields
private double annualsalary;
private double annualproduction;
//constructor
public ShiftSupervisor(String Empname, String
Empnumber, String Hiredate, double annualsalary, double
annualproduction)
{
super(Empname,
Empnumber,Hiredate);
setAnuaSal (annualsalary);
setAnuPro (annualproduction);
}
// accessor
public double getAnuaSal()
{
return annualsalary;
}
public double getAnuPro()
{
return annualproduction;
}
// mutator
public void setAnuSal (double s)
{
annualsalary = s;
}
public void setAnuPro (double p)
{
annualproduction = p;
}
public String toString()
{
return "
Name:"+getName()+"\nEmpID:"+getNumber()+"\nHire
Date:"+getHireDate()+"\nAnnual Salary:"+annualsalary+
"\nProduction"+annualproduction;
}
private void setAnuaSal(double annualsalary) {
throw new
UnsupportedOperationException("Not supported yet."); //To change
body of generated methods, choose Tools | Templates.
}
}
############## Demo class #########
public class ShiftEmployeeTest {
public static void main(String[] args) {
ShiftSupervisor emp = new ShiftSupervisor("Pravesh", "12A", "11/12/2000", 432123, 43);
System.out.println(emp);
System.out.println("\nAnnual salary: "+emp.getAnuaSal());
}
}
/*
Sample run:
Name:Pravesh
EmpID:12A
Hire Date:11/12/2000
Annual Salary:432123.0
Production43.0
Annual salary: 432123.0
*/