public abstract class Employee
{
private String firstName;
private String lastName;
private String socialSecurityNumber;
public Employee(String first, String last, String ssn)
{
firstName = first;
lastName = last;
socialSecurityNumber = ssn;
}
// Set first name
public void setFirstName(String first)
{
firstName = first;
}
public String getFirstName()
{
return firstName;
}
public void setLastName(String last)
{
lastName = last;
}
public String getLastName()
{
return lastName;
}
public void setSocialSecurityNumber(String ssn)
{
socialSecurityNumber = ssn;
}
public String getSocialSecurityNumber()
{
return socialSecurityNumber;
}
public String toString()
{
return String.format( "%s %s\nsocial security number: %s", getFirstName(), getLastName(), getSocialSecurityNumber() );
}
public abstract double earnings();
}
This needed an addition to "PieceWorker" in a subclass. I need some input and dialog to fix this. This is the work that I have done. Thanks. PieceWorker should represents an employee who's pay is based on the number of pieces of merchandise produced? Also should contain private instance variable wage (to store the employee's wage per piece) and pieces (to store the number of pieces produced). Concrete method earnings in class PieceWorker that calculates the employee's earnings by multiplying the number of pieces produced by the wage per pieces. Also an array variables to store reference to objects of each concret class in the new Employee hierarchy.

New Topic/Question
Reply




MultiQuote



|