-
Notifications
You must be signed in to change notification settings - Fork 0
/
Woman.java
46 lines (34 loc) · 920 Bytes
/
Woman.java
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
import java.util.*;
public class Woman {
private String name;
private ArrayList<Man> partners;
public Woman(String name){
this.name = name;
partners = new ArrayList<Man>();
}
public void addMan(Man man){
partners.add(man);
}
public String toString(){
return name;
}
public void setPartners(ArrayList<Man> partners){
this.partners = partners;
}
public Woman(String name, ArrayList<Man> list) {
this.name = name;
partners = list;
}
public String getName() {
return name;
}
public boolean equals(Object other) {
return getName().equals(((Woman) other).getName());
}
public Man getMan(int i){
return partners.get(i);
}
public int compareTo(Object other){
return getName().compareTo(((Woman)other).getName());
}
}