Line | |
---|
1 | // ComparableDouble.java |
---|
2 | // |
---|
3 | // (c) 1999-2001 PAL Development Core Team |
---|
4 | // |
---|
5 | // This package may be distributed under the |
---|
6 | // terms of the Lesser GNU General Public License (LGPL) |
---|
7 | |
---|
8 | package de.ugoe.cs.autoquest.tasktrees.alignment.pal.util; |
---|
9 | |
---|
10 | /** |
---|
11 | * This class is unfortunate but necessary to conform to JDK 1.1 |
---|
12 | * |
---|
13 | * @version $Id: ComparableDouble.java,v 1.3 2001/07/13 14:39:13 korbinian Exp $ |
---|
14 | * |
---|
15 | * @author Alexei Drummond |
---|
16 | */ |
---|
17 | public class ComparableDouble implements Comparable { |
---|
18 | |
---|
19 | private double value; |
---|
20 | |
---|
21 | public ComparableDouble(double d) { |
---|
22 | value = d; |
---|
23 | } |
---|
24 | |
---|
25 | public int compareTo(Object o) { |
---|
26 | |
---|
27 | ComparableDouble cd = (ComparableDouble)o; |
---|
28 | |
---|
29 | if (value < cd.value) { |
---|
30 | return -1; |
---|
31 | } else if (value > cd.value) { |
---|
32 | return 1; |
---|
33 | } else return 0; |
---|
34 | } |
---|
35 | |
---|
36 | public boolean equals(Object o) { |
---|
37 | |
---|
38 | ComparableDouble cd = (ComparableDouble)o; |
---|
39 | return cd.value == value; |
---|
40 | } |
---|
41 | |
---|
42 | public double doubleValue() { |
---|
43 | return value; |
---|
44 | } |
---|
45 | |
---|
46 | public String toString() { |
---|
47 | return value + ""; |
---|
48 | } |
---|
49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.