-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeam.java
More file actions
30 lines (21 loc) · 684 Bytes
/
Copy pathTeam.java
File metadata and controls
30 lines (21 loc) · 684 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
package hashCodeEquals;
class Team {
String city;
String department;
public Team(String city, String department) {
this.city = city;
this.department = department;
}
@Override
public final boolean equals(Object obj) {
if (obj == this) // same object is passed
return true;
if (!(obj instanceof Object))
return false;
Team otherObj = (Team) obj;
boolean isCurrenyCodeEqual = (this.city == null && otherObj.city == null) || (this.city.equals(otherObj.city));
boolean isDepartmentEqual = (this.department == null && otherObj.department == null)
|| (this.department.equals(otherObj.department));
return isCurrenyCodeEqual && isDepartmentEqual;
}
}