Question: package ex 1 inheritance; / * * * * @author athee * / public class Ex 1 Inheritance { public static void main ( String

package ex1inheritance;
/**
*
* @author athee
*/
public class Ex1Inheritance {
public static void main(String[] args){
ProductionWorker workerOne = new ProductionWorker("John Smith", "123-A","11-15-2005",1,16.50);
ProductionWorker workerTwo = new ProductionWorker("Joan Jones", "222-L","12-12-2005",2,18.50);
System.out.println("Here's the first production worker:
"+ workerOne);
System.out.println("
Here's the second production worker:
"+ workerTwo);
}
}
public class Employee {
private String name;
private String employeeNumber;
private String hireDate;
public Employee(String name, String employeeNumber, String hireDate){
this.name = name;
this.employeeNumber = employeeNumber;
this.hireDate = hireDate;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String getEmployeeNumber(){
return employeeNumber;
}
public void setEmployeeNumber(String employeeNumber){
this.employeeNumber = employeeNumber;
}
public String getHireDate(){
return hireDate;
}
public void setHireDate(String hireDate){
this.hireDate = hireDate;
}
}
public class ProductionWorker extends Employee {
private int shift;
private double payRate;
public ProductionWorker(String name, String employeeNumber, String hireDate, int shift, double payRate){
super(name, employeeNumber, hireDate);
this.shift = shift;
this.payRate = payRate;
}
public int getShift(){
return shift;
}
public void setShift(int shift){
this.shift = shift;
}
public double getPayRate(){
return payRate;
}
public void setPayRate(double payRate){
this.payRate = payRate;
}
@Override
public String toString(){
String shiftType =(shift ==1)? "day" : "night";
return "Name: "+ getName()+"
Employee Number: "+ getEmployeeNumber()+"
Hire Date: "+ getHireDate()
+"
Shift: "+ shiftType +"
Hourly Pay Rate: $"+ payRate;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!