Last change
on this file since 1324 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:
892 bytes
|
Rev | Line | |
---|
[44] | 1 | package cecj.interaction; |
---|
| 2 | |
---|
| 3 | /** |
---|
| 4 | * Immutable class representing real-valued interaction results. |
---|
| 5 | * |
---|
| 6 | * @author Marcin Szubert |
---|
| 7 | * |
---|
| 8 | */ |
---|
| 9 | public class RealValuedResult implements InteractionResult { |
---|
| 10 | |
---|
| 11 | private float value; |
---|
| 12 | |
---|
| 13 | public RealValuedResult(float value) { |
---|
| 14 | this.value = value; |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | public boolean betterThan(InteractionResult other) { |
---|
| 18 | if (!(other instanceof RealValuedResult)) { |
---|
| 19 | throw new IllegalArgumentException( |
---|
| 20 | "Interaction result comparison must be done within the same type of results."); |
---|
| 21 | } else { |
---|
| 22 | return (this.value > ((RealValuedResult) other).value); |
---|
| 23 | } |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | public float getNumericValue() { |
---|
| 27 | return value; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | @Override |
---|
| 31 | public boolean equals(Object obj) { |
---|
| 32 | if (!(obj instanceof RealValuedResult)) { |
---|
| 33 | return false; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | return (((RealValuedResult) obj).value == this.value); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | @Override |
---|
| 40 | public String toString() { |
---|
| 41 | return Float.toString(value); |
---|
| 42 | } |
---|
| 43 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.