Line | |
---|
1 | package geniusweb.exampleparties.nataliaparty;
|
---|
2 |
|
---|
3 | import geniusweb.issuevalue.Value;
|
---|
4 |
|
---|
5 | public class ValueOption implements Comparable<ValueOption> {
|
---|
6 |
|
---|
7 | private String issue;
|
---|
8 | private Value value;
|
---|
9 | private double penalty;
|
---|
10 |
|
---|
11 | public ValueOption(String issue, Value value, double penalty) {
|
---|
12 | this.issue = issue;
|
---|
13 | this.value = value;
|
---|
14 | this.penalty = penalty;
|
---|
15 | }
|
---|
16 |
|
---|
17 | public String getIssue() {
|
---|
18 | return issue;
|
---|
19 | }
|
---|
20 |
|
---|
21 | public Value getValue() {
|
---|
22 | return value;
|
---|
23 | }
|
---|
24 |
|
---|
25 | public double getPenalty() {
|
---|
26 | return penalty;
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public int compareTo(ValueOption o) {
|
---|
31 | if (penalty == o.penalty) {
|
---|
32 | return value.toString().compareTo(o.value.toString());
|
---|
33 | }
|
---|
34 | return penalty > o.penalty ? 1 : -1;
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | public String toString() {
|
---|
39 | return issue + " = " + value + " (" + penalty + ")";
|
---|
40 | }
|
---|
41 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.