-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTeam.java
41 lines (36 loc) · 1007 Bytes
/
Team.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
import java.util.*;
class Team implements Comparable<Team>{
public String name;
public League homeLeague;
public League currentLeague;
public int points;
public int probabilityNumber;
public Team(String myName, League myHomeLeague, League myCurrentLeague, int myPoints) {
probabilityNumber = myPoints;
name = myName;
homeLeague = myHomeLeague;
currentLeague = myCurrentLeague;
points = myPoints;
}
public String toString(){
return ("" + points + " " + name);
}
public boolean equals(Object o) {
if (!(o instanceof Team))
return false;
Team t = (Team) o;
Integer myPoints = points;
Integer tPoints = t.points;
return (tPoints.equals(myPoints));
}
public int hashCode(){
Integer myPoints = points;
return 31 * myPoints.hashCode();
}
public int compareTo(Team t){
Integer myPoints = points;
Integer tPoints = t.points;
int ptsComp = tPoints.compareTo(myPoints);
return (ptsComp !=0 ? ptsComp : name.compareTo(t.name));
}
}