By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,563 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,563 IT Pros & Developers. It's quick & easy.

Employee Class abstract

P: 14
Can some help me with this. Please review this code for errors. I can not get it to complie.

Here is my Code .. This is an abstract class that is used in conjuntion with 4 other classes.. They are Hourly, IAm, Salaried, Sales.

import java.util.*;

//Constructors

//Constructor
public abstract class Employee
extends java.lang.Object{

private int empID, zip;
private String lastName, firstName, address;

public abstract double getPay(); //Abstract Methods

public Employee(int empID, java.lang.String lastName,
java.lang.String firstName,
java.util.GregorianCalendar hireDate,
java.lang.String address, int zip) {
this(empID, lastName, firstName, hireDate,
address, zip, null);
}

public Employee(int empID, java.lang.String lastName,
java.lang.String firstName,
java.util.GregorianCalendar hireDate,
java.lang.String address, int zip,
java.util.GregorianCalendar termDate) {
setEmployeeID(empID);
setLastName(lastName);
setFirstName(firstName);
setHireDate(hireDate);
setAddress(address);
setZip(zip);
setTermDate(termDate);
}

public final void setAddress(String address) {
this.address = address;
} //set address

public String getAddress() {
return address;
} //get address

public void setEmployeeID(int empID) {
this.empID = empID;
} //set EmployeeID

public int getEmployeeID() {
return empID;
} //get EmployeeID

public void setLastName(java.lang.String lastName) {
this.lastName = lastName;
} //set lastName

public java.lang.String getLastName() {
return lastName;
} //getLastName

public void setFirstName(java.lang.String firstName) {
this.firstName = firstName;
} //setFirstName

public java.lang.String getFirstName() {
return firstName;
} //getFirstName

//sets fullname to firstName+lastName
public final java.lang.String getFullName() {
this.fullName = firstName + lastName;
} //gets employee's full name

public java.lang.String getFullName() {
return FullName = firstName() + lastName();
} // returns fullname as firstname + lastname

public final void setHireDate(java.util.GregorianCalendar hireDate) {
this.hireDate = hireDate;
} //sets hiredate of employee

public final java.util.GregorianCalendar getHireDate() {
return hireDate = hiredate;
} //returns hireDate of employee

public final java.util.GregorianCalendar getTermDate() {
return termDate = termdate;
} //get's employee's termination date

public final void setTermDate(java.util.GregorianCalendar termDate) {
this.setTermDate(termDate);
} //sets employee's termination date

public void setZip(int Zip) {
this.setZip(Zip);
} //setZip Code

public int getZip() {
return zip = zip;
} //returns employee's zip Code

public java.lang.String getCity() {
return city = city;
} //returns employee's city

public final java.lang.String getState() {
return state = state;
} //returns employee's state

public final java.lang.String getCityState() {
return getCityState = City() + State();
} //getCityState returns the employee's city and state based on zipcode

//the employee's city and state as "City,State"
public java.lang.String toString() { //returns the employee's sorted name as LastName, FirstName
} //toString overides in class java.lang.Object
//returns the employees full name -- example "Smith,Sue"
protected boolean isPaid(){// isPaid determines if the employee is paid or not.

}//returns a true if the employee is paid : false if the employee is not paid
//if termination date is null, return true.. if termination date is not null then
//return false. use method getTermDate()
public static java.lang.String getProgrammer(){// getProgrammer returns the name of the Programmer

}//returns my name from the method getName in the IAm Class of this Project.
}
Nov 17 '06 #1
Share this Question
Share on Google+
3 Replies


10K+
P: 13,264
Can some help me with this. Please review this code for errors. I can not get it to complie.

Here is my Code .. This is an abstract class that is used in conjuntion with 4 other classes.. They are Hourly, IAm, Salaried, Sales.

import java.util.*;

//Constructors

//Constructor
public abstract class Employee
extends java.lang.Object{

private int empID, zip;
private String lastName, firstName, address;

public abstract double getPay(); //Abstract Methods

public Employee(int empID, java.lang.String lastName,
java.lang.String firstName,
java.util.GregorianCalendar hireDate,
java.lang.String address, int zip) {
this(empID, lastName, firstName, hireDate,
address, zip, null);
}

public Employee(int empID, java.lang.String lastName,
java.lang.String firstName,
java.util.GregorianCalendar hireDate,
java.lang.String address, int zip,
java.util.GregorianCalendar termDate) {
setEmployeeID(empID);
setLastName(lastName);
setFirstName(firstName);
setHireDate(hireDate);
setAddress(address);
setZip(zip);
setTermDate(termDate);
}

public final void setAddress(String address) {
this.address = address;
} //set address

public String getAddress() {
return address;
} //get address

public void setEmployeeID(int empID) {
this.empID = empID;
} //set EmployeeID

public int getEmployeeID() {
return empID;
} //get EmployeeID

public void setLastName(java.lang.String lastName) {
this.lastName = lastName;
} //set lastName

public java.lang.String getLastName() {
return lastName;
} //getLastName

public void setFirstName(java.lang.String firstName) {
this.firstName = firstName;
} //setFirstName

public java.lang.String getFirstName() {
return firstName;
} //getFirstName

//sets fullname to firstName+lastName
public final java.lang.String getFullName() {
this.fullName = firstName + lastName;
} //gets employee's full name

public java.lang.String getFullName() {
return FullName = firstName() + lastName();
} // returns fullname as firstname + lastname

public final void setHireDate(java.util.GregorianCalendar hireDate) {
this.hireDate = hireDate;
} //sets hiredate of employee

public final java.util.GregorianCalendar getHireDate() {
return hireDate = hiredate;
} //returns hireDate of employee

public final java.util.GregorianCalendar getTermDate() {
return termDate = termdate;
} //get's employee's termination date

public final void setTermDate(java.util.GregorianCalendar termDate) {
this.setTermDate(termDate);
} //sets employee's termination date

public void setZip(int Zip) {
this.setZip(Zip);
} //setZip Code

public int getZip() {
return zip = zip;
} //returns employee's zip Code

public java.lang.String getCity() {
return city = city;
} //returns employee's city

public final java.lang.String getState() {
return state = state;
} //returns employee's state

public final java.lang.String getCityState() {
return getCityState = City() + State();
} //getCityState returns the employee's city and state based on zipcode

//the employee's city and state as "City,State"
public java.lang.String toString() { //returns the employee's sorted name as LastName, FirstName
} //toString overides in class java.lang.Object
//returns the employees full name -- example "Smith,Sue"
protected boolean isPaid(){// isPaid determines if the employee is paid or not.

}//returns a true if the employee is paid : false if the employee is not paid
//if termination date is null, return true.. if termination date is not null then
//return false. use method getTermDate()
public static java.lang.String getProgrammer(){// getProgrammer returns the name of the Programmer

}//returns my name from the method getName in the IAm Class of this Project.
}
The code looks very bad. I think you should revisit the tutorials on methods and classes before you continue. I have made it compile but it is still very bad. Also read the tutorials on how to use import statements.



Expand|Select|Wrap|Line Numbers
  1.  import java.util.*; 
  2. //Constructors
  3. //Constructor
  4. public abstract class Employee
  5. extends java.lang.Object{
  6. private int empID, zip;
  7. private String lastName, firstName, address, fullName, city, state;
  8. java.util.GregorianCalendar hireDate;
  9. java.util.GregorianCalendar termDate;
  10.  
  11. public abstract double getPay(); //Abstract Methods
  12. public Employee(int empID, java.lang.String lastName,
  13. java.lang.String firstName,
  14. java.util.GregorianCalendar hireDate,
  15. java.lang.String address, int zip) {
  16. this(empID, lastName, firstName, hireDate,
  17. address, zip, null);
  18. }
  19. public Employee(int empID, java.lang.String lastName,
  20. java.lang.String firstName,
  21. java.util.GregorianCalendar hireDate,
  22. java.lang.String address, int zip,
  23. java.util.GregorianCalendar termDate) {
  24. setEmployeeID(empID);
  25. setLastName(lastName);
  26. setFirstName(firstName);
  27. setHireDate(hireDate);
  28. setAddress(address);
  29. setZip(zip);
  30. setTermDate(termDate);
  31. }
  32. public final void setAddress(String address) {
  33. this.address = address;
  34. } //set address
  35. public String getAddress() {
  36. return address;
  37. } //get address
  38. public void setEmployeeID(int empID) {
  39. this.empID = empID;
  40. } //set EmployeeID
  41. public int getEmployeeID() {
  42. return empID;
  43. } //get EmployeeID
  44. public void setLastName(java.lang.String lastName) {
  45. this.lastName = lastName;
  46. } //set lastName
  47. public java.lang.String getLastName() {
  48. return lastName;
  49. } //getLastName
  50. public void setFirstName(java.lang.String firstName) {
  51. this.firstName = firstName;
  52. } //setFirstName
  53. public java.lang.String getFirstName() {
  54. return firstName;
  55. } //getFirstName
  56. //sets fullname to firstName+lastName
  57. public final void setFullName(String firstName, String lastName) {
  58. this.fullName = firstName + lastName;
  59. } //gets employee's full name
  60. public java.lang.String getFullName() {
  61. return fullName;
  62. } // returns fullname as firstname + lastname
  63. public final void setHireDate(java.util.GregorianCalendar hireDate) {
  64. this.hireDate = hireDate;
  65. } //sets hiredate of employee
  66. public final java.util.GregorianCalendar getHireDate() {
  67. return hireDate = hireDate;
  68. } //returns hireDate of employee
  69. public final java.util.GregorianCalendar getTermDate() {
  70. return termDate;
  71. } //get's employee's termination date
  72. public final void setTermDate(java.util.GregorianCalendar termDate) {
  73. this.termDate = termDate;
  74. } //sets employee's termination date
  75. public void setZip(int Zip) {
  76. this.setZip(Zip);
  77. } //setZip Code
  78. public int getZip() {
  79. return zip = zip;
  80. } //returns employee's zip Code
  81. public java.lang.String getCity() {
  82. return this.city;
  83. } //returns employee's city
  84. public final java.lang.String getState() {
  85. return state;
  86. } //returns employee's state
  87. public final java.lang.String getCityState() {
  88. return city + state;
  89. } //getCityState returns the employee's city and state based on zipcode
  90. //the employee's city and state as "City,State"
  91. //public java.lang.String toString() { //returns the employee's sorted name as LastName, FirstName
  92. //} //toString overides in class java.lang.Object
  93. //returns the employees full name -- example "Smith,Sue"
  94. //protected boolean isPaid(){// isPaid determines if the employee is paid or not.
  95. //}//returns a true if the employee is paid : false if the employee is not paid
  96. //if termination date is null, return true.. if termination date is not null then
  97. //return false. use method getTermDate()
  98. //public static java.lang.String getProgrammer(){// getProgrammer returns the name of the Programmer
  99. //}//returns my name from the method getName in the IAm Class of this Project.
  100. }
  101.  
  102.  
Nov 18 '06 #2

P: 14
Thanks I will try the revisions tonight. one of my problems is that the teacher i have runs very fast. Here says and add this and then this and this and then this and then complie and oh at this and fix this and fix this and then compile and then add this and then complile and oh fix this error and now done. ok now fix this example. We are going can you slow that down a bit... That is why I am here. You guys are teaching me more. Most of the code you see is from his handout. java.lang.util and the messy stuff we have not done. but it is in this exercise.

Thanks any help you can give to help me understand this is great.

John
Nov 18 '06 #3

P: 14
If someone knows some dazzle code for this I sure would like to see it. Sorry for all the comments.. Just wanted you to have as much information as I do.

Thanks
john
Nov 18 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.