-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee.java
More file actions
40 lines (34 loc) · 1.1 KB
/
Employee.java
File metadata and controls
40 lines (34 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Write a description of class Employee here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Employee implements Comparable<Employee>
{
private String firstName;
private String lastName;
private int birthYear;
public Employee(String f, String l, int year)
{
firstName = f;
lastName = l;
birthYear = year;
}
public String getFirstName() {return firstName;}
public String getLastName() {return lastName;}
public int getBirthYear() {return birthYear;}
public String toString()
{
return getFirstName() + " " + getLastName() + " " + getBirthYear();
}
public int compareTo(Employee other) {
if(getLastName().equals(other.getLastName())) {
if(getFirstName().equals(other.getFirstName())) {
return getBirthYear()-other.getBirthYear();
}
else return getFirstName().compareTo(other.getFirstName());
}
else return getLastName().compareTo(other.getLastName());
}
}