Java programming – Class/Bean with Constructors, Properties, Setters/Getters and toString method

Employee

 


 

public class Employee {
private int empNum;
private String firstName;
private String lastName;
private String initials;
private char sex;
private String phoneNumber;
private double salary;
private boolean workStatus;

public Employee() {}

public Employee(int empNum,
String firstName,
String lastName,
String initials,
char sex,
String phoneNumber,
double salary,
boolean workStatus) {
this.empNum = empNum;
this.firstName = firstName;
this.lastName = lastName;
this.initials = initials;
this.phoneNumber = phoneNumber;
this.salary = salary;
this.sex = sex;
this.workStatus = workStatus;
}

public Employee(int empNum) {
this.empNum = empNum;

}

public Employee(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}

/**
* @return the empNum
*/
public int getEmpNum() {
return empNum;
}

/**
* @param empNum the empNum to set
*/
public void setEmpNum(int empNum) {
this.empNum = empNum;
}

/**
* @return the firstName
*/
public String getFirstName() {
return firstName;
}

/**
* @param firstName the firstName to set
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}

/**
* @return the lastName
*/
public String getLastName() {
return lastName;
}

/**
* @param lastName the lastName to set
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}

/**
* @return the initials
*/
public String getInitials() {
return initials;
}

/**
* @param initials the initials to set
*/
public void setInitials(String initials) {
this.initials = initials;
}

/**
* @return the sex
*/
public char getSex() {
return sex;
}

/**
* @param sex the sex to set
*/
public void setSex(char sex) {
this.sex = sex;
}

/**
* @return the phoneNumber
*/
public String getPhoneNumber() {
return phoneNumber;
}

/**
* @param phoneNumber the phoneNumber to set
*/
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}

/**
* @return the salary
*/
public double getSalary() {
return salary;
}

/**
* @param salary the salary to set
*/
public void setSalary(double salary) {
this.salary = salary;
}

/**
* @return the workStatus
*/
public boolean isWorkStatus() {
return workStatus;
}

/**
* @param workStatus the workStatus to set
*/
public void setWorkStatus(boolean workStatus) {
this.workStatus = workStatus;
}

/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return “Employee [empNum=” + empNum + “, firstName=” + firstName
+ “, lastName=” + lastName + “, initials=” + initials
+ “, sex=” + sex + “, phoneNumber=” + phoneNumber + “, salary=”
+ salary + “, workStatus=” + workStatus + “]”;
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s