-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBrother.java
83 lines (67 loc) · 2.05 KB
/
Brother.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
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 Brother implements Comparable<Brother> {
private int iNum;
private String initials, name;
private boolean coopStatus, inHouse, positionStatus;
public Brother (int iNum, String initials, String name,
boolean coopStatus, boolean inHouse, boolean positionStatus) {
this.iNum = iNum;
this.initials = initials;
this.name = name;
this.coopStatus = coopStatus;
this.inHouse = inHouse;
this.positionStatus = positionStatus;
}
@Override
public int compareTo(Brother other) {
return this.iNum - other.iNum;
}
@Override
public boolean equals(Object other) {
if (other == null) {return false;}
if (!(other instanceof Brother)) {return false;}
return this.hashCode() == other.hashCode();
}
@Override
public int hashCode() {
return iNum;
}
public int getINum() {
return iNum;
}
public String getInitials() {
return initials;
}
public String getName() {
return name;
}
public boolean getCoopStatus() {
return coopStatus;
}
public boolean getInHouse() {
return inHouse;
}
public boolean getPositionStatus() {
return positionStatus;
}
public void setCoopStatus(boolean newStatus) {
coopStatus = newStatus;
}
public void setInHouse(boolean newStatus) {
inHouse = newStatus;
}
public void setPositionStatus(boolean newStatus) {
positionStatus = newStatus;
}
@Override
public String toString() {
String s = "";
String housePhrase = "";
String coopPhrase = "";
String positionPhrase = "";
if (!inHouse) {housePhrase = "not ";}
if (coopStatus) {coopPhrase = "\nIs currently in a Co-Op.";}
if (positionStatus) {positionPhrase = "\nIs currently holding a priority position.";}
s = "I-%d %s. \nIs currently %sliving in the house.%s%s";
return String.format(s, iNum, name, housePhrase, coopPhrase, positionPhrase);
}
}