In: Computer Science
EmployeeClient.java
public class EmployeeClient {
public static void main(String[] args) {
Employee emp = new
Employee();
emp.setFirstName("John");
emp.setLastName("Doe");
emp.setYearsEmployed(4.5);
System.out.println(emp);
}
}
Employee.java
public class Employee {
private String firstName , lastName ;
private double yearsEmployed ;
public Employee() {
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public double getYearsEmployed() {
return yearsEmployed;
}
public void setYearsEmployed(double yearsEmployed)
{
this.yearsEmployed =
yearsEmployed;
}
public String toString() {
return "Name: "+firstName+"
"+lastName+", yearsEmployed: "+yearsEmployed;
}
}
Output:
Name: John Doe, yearsEmployed: 4.5