-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoredChampion.java
More file actions
29 lines (25 loc) · 848 Bytes
/
Copy pathScoredChampion.java
File metadata and controls
29 lines (25 loc) · 848 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
import java.text.DecimalFormat;
/**
* A small wrapper object to contain both a champion's name and its calculated score/winrate
* (more on the distinction between score/winrate in README)
* Contains a .toString() method for easier printing and a compareTo for ordering
*/
public class ScoredChampion implements Comparable<ScoredChampion> {
public double winRate;
public String champion;
public ScoredChampion(String champion, double wR) {
this.champion = champion;
this.winRate = wR;
}
public String toString() {
DecimalFormat df = new DecimalFormat("###.##");
return champion + ", " + df.format(winRate*100) + "%";
}
public int compareTo(ScoredChampion other) {
double diff = this.winRate - other.winRate;
if (diff != 0) {
return (int) (diff/Math.abs(diff));
}
return this.champion.compareTo(other.champion);
}
}