Last change
on this file since 1114 was
193,
checked in by Maciej Komosinski, 11 years ago
|
Set svn:eol-style native for all textual files
|
-
Property svn:eol-style set to
native
|
File size:
799 bytes
|
Line | |
---|
1 | package cecj.interaction; |
---|
2 | |
---|
3 | public class WinDrawLossResult implements InteractionResult { |
---|
4 | |
---|
5 | public enum Result { |
---|
6 | LOSS, DRAW, WIN |
---|
7 | } |
---|
8 | |
---|
9 | private Result result; |
---|
10 | |
---|
11 | public WinDrawLossResult(Result result) { |
---|
12 | this.result = result; |
---|
13 | } |
---|
14 | |
---|
15 | public boolean betterThan(InteractionResult other) { |
---|
16 | if (!(other instanceof WinDrawLossResult)) { |
---|
17 | throw new IllegalArgumentException( |
---|
18 | "Interaction result comparison must be done within the same type of results."); |
---|
19 | } else { |
---|
20 | return (this.result.ordinal() > ((WinDrawLossResult) other).result.ordinal()); |
---|
21 | } |
---|
22 | } |
---|
23 | |
---|
24 | public float getNumericValue() { |
---|
25 | if (result == Result.LOSS) { |
---|
26 | return 0; |
---|
27 | } else if (result == Result.DRAW) { |
---|
28 | return 1; |
---|
29 | } else { |
---|
30 | return 3; |
---|
31 | } |
---|
32 | } |
---|
33 | |
---|
34 | @Override |
---|
35 | public String toString() { |
---|
36 | return result.name().charAt(0) + ""; |
---|
37 | } |
---|
38 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.