-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.java
More file actions
executable file
·83 lines (73 loc) · 1.32 KB
/
Copy pathPerson.java
File metadata and controls
executable file
·83 lines (73 loc) · 1.32 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
public class Person implements Comparable
{
String firstName ;
String lastName ;
int birthMonth ;
int dayOfBirth ;
int yearOfBirth ;
public Person(String fN, String lN, int month, int day, int year)
{
firstName = fN ;
lastName = lN ;
birthMonth = month ;
dayOfBirth = day ;
yearOfBirth = year ;
}
public int compareTo(Object ob)
{
Person obj = (Person)ob ;
if(getYear() != obj.getYear())
{
if(getYear() > obj.getYear())
{
return 1 ;
}
else return -1 ;
}
else if(getMonth() != obj.getMonth())
{
if(getMonth() > obj.getMonth())
{
return 1 ;
}
else return -1 ;
}
else if(getDay() != obj.getDay())
{
if(getDay() > obj.getDay())
{
return 1 ;
}
else return -1 ;
}
else if(getLastName().equals(obj.getLastName()))
{
return getLastName().compareTo(obj.getLastName()) ;
}
else if(getFirstName().equals(obj.getFirstName()))
{
return getFirstName().compareTo(obj.getFirstName()) ;
}
else return 0 ;
}
public String getFirstName()
{
return firstName ;
}
public String getLastName()
{
return lastName ;
}
public int getMonth()
{
return birthMonth ;
}
public int getDay()
{
return dayOfBirth ;
}
public int getYear()
{
return yearOfBirth ;
}
}