-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarriage.java
More file actions
35 lines (26 loc) · 798 Bytes
/
Marriage.java
File metadata and controls
35 lines (26 loc) · 798 Bytes
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
import java.util.*;
public class Marriage implements Comparable {
private Man guy;
private Woman girl;
public Marriage(Man dude, Woman chick){
guy = dude;
girl = chick;
}
public String toString(){
return guy.getName() + " " + girl.getName();
}
public int compareTo(Object other){
if (getMan().equals(((Marriage)other).getMan()) || getWoman().equals(((Marriage)other).getWoman()))
return 0;
return 1;
}
public Man getMan(){
return guy;
}
public Woman getWoman(){
return girl;
}
public boolean equals(Object other){
return getMan().equals(((Marriage)other).getMan()) || getWoman().equals(((Marriage)other).getWoman());
}
}