Line | |
---|
1 | package geniusweb.exampleparties.anaconda;
|
---|
2 |
|
---|
3 | import java.util.Comparator;
|
---|
4 |
|
---|
5 | import geniusweb.issuevalue.Value;
|
---|
6 |
|
---|
7 | public class impUnit {
|
---|
8 | public Value valueOfIssue;
|
---|
9 | public int victories = 0;
|
---|
10 | public int total_count = 0;
|
---|
11 | public double probability = 0.0f;
|
---|
12 |
|
---|
13 | public impUnit(Value value) {
|
---|
14 | this.valueOfIssue = value;
|
---|
15 | }
|
---|
16 |
|
---|
17 | public String toString() {
|
---|
18 | return String.format("%s %f", valueOfIssue, probability);
|
---|
19 | }
|
---|
20 |
|
---|
21 | // Overriding the comparator interface
|
---|
22 | static class meanWeightSumComparator implements Comparator<impUnit> {
|
---|
23 | public int compare(impUnit o1, impUnit o2) {
|
---|
24 | if (o1.probability < o2.probability) {
|
---|
25 | return 1;
|
---|
26 | } else if (o1.probability > o2.probability) {
|
---|
27 | return -1;
|
---|
28 | }
|
---|
29 | return 0;
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | // Overriding the comparator interface
|
---|
34 | static class impSumComparator implements Comparator<impUnit> {
|
---|
35 | public int compare(impUnit o1, impUnit o2) {
|
---|
36 | if (o1.total_count < o2.total_count) {
|
---|
37 | return 1;
|
---|
38 | } else if (o1.total_count > o2.total_count) {
|
---|
39 | return -1;
|
---|
40 | }
|
---|
41 | return 0;
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.