Can this Class be cleaned up at all?
- From: John T <printdude1968@xxxxxxxxx>
- Date: Sun, 25 Feb 2007 01:08:01 GMT
Here's a class I wrote:
package employees;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Employee {
private int employeeNumber;
private String employeeName;
private Date hireDate;
private float initialSalary;
private String jobTitle;
public Employee(int employeeNumber, String employeeName, Calendar date, float initialSalary, String jobTitle) {
this.employeeNumber = employeeNumber;
this.employeeName = employeeName;
this.initialSalary = initialSalary;
this.jobTitle = jobTitle;
this.hireDate = date.getTime();
}
public Employee(int employeeNumber, String employeeName, Calendar date, float initialSalary) {
this.employeeNumber = employeeNumber;
this.employeeName = employeeName;
this.initialSalary = initialSalary;
this.hireDate = date.getTime();
}
void displayAll () {
System.out.println("Employee Information");
System.out.println("Employee Name: " + employeeName);
System.out.println("Employee Number: " + employeeNumber);
System.out.println("Initial Salary: " + initialSalary);
System.out.println("Job Title: " + jobTitle);
this.displayHireDate();
}
void displayHireDate()
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
System.out.println("Hire Date: " + sdf.format(this.hireDate));
}
public String getEmployeeName() {
return employeeName;
}
public void setEmployeeName(String employeeName) {
this.employeeName = employeeName;
}
public int getEmployeeNumber() {
return employeeNumber;
}
public void setEmployeeNumber(int employeeNumber) {
this.employeeNumber = employeeNumber;
}
public Date getHireDate() {
return hireDate;
}
public void setHireDate(Calendar c) {
this.hireDate = c.getTime();
}
public float getInitialSalary() {
return initialSalary;
}
public void setInitialSalary(float initialSalary) {
this.initialSalary = initialSalary;
}
public String getJobTitle() {
return jobTitle;
}
public void setJobTitle(String jobTitle) {
this.jobTitle = jobTitle;
}
}
Is there anything that can be changed to make it look less clunky? I was thinking about making it an interface and having it implemented but when I thought about the IS-A HAS-A guideline I thought it would make more sense to have the Employee class and an interface called EmployeeDoes to encapsulate the methods.
Any thoughts?
.
- Follow-Ups:
- Re: Can this Class be cleaned up at all?
- From: Lew
- Re: Can this Class be cleaned up at all?
- From: Patricia Shanahan
- Re: Can this Class be cleaned up at all?
- From: hiwa
- Re: Can this Class be cleaned up at all?
- Prev by Date: Re: Unchecked compiler warning
- Next by Date: Re: Can this Class be cleaned up at all?
- Previous by thread: Unchecked compiler warning
- Next by thread: Re: Can this Class be cleaned up at all?
- Index(es):
Relevant Pages
|
|