Payroll System in Java

Include subclass "PieceWorker" issue

Page 1 of 1

1 Replies - 9424 Views - Last Post: 12 April 2007 - 01:50 AM Rate Topic: -----

#1 pcnote  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 24-February 07

Payroll System in Java

Post icon  Posted 11 April 2007 - 11:18 PM


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.

Is This A Good Question/Topic? 0
  • +

Replies To: Payroll System in Java

#2 Ellie  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 8
  • View blog
  • Posts: 533
  • Joined: 17-January 07

Re: Payroll System in Java

Posted 12 April 2007 - 01:50 AM

I think you'll probably need to post some beginnings of your pieceworker class for anyone to really help you with this problem.

Now that you've got the Employee class, you need to create a new pieceworker class that extends the Employee class

public class Pieceworker extends Employee {

private int wage;
private int pieces;
private int earnings;

public Pieceworker (String f, String l, String s, int w) 
{
super(f, l, s);
wage = w;
pieces = 0;
earnings = 0;
}



That should be a start :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1