Initial revision
[old-projects.git] / ekit / com / swabunga / spell / engine / Word.java
CommitLineData
6dd70280
JL
1package com.swabunga.spell.engine;\r\r
2\r\r
3import java.util.Comparator;\r\r
4\r\r
5/** The Word object holds both the string and the score.\r\r
6 * <p>This class is now immutable.\r\r
7 * </p>\r\r
8 */\r\r
9public class Word implements Comparator {\r\r
10 private String word;\r\r
11 private int score;\r\r
12\r\r
13 public Word() { \r\r
14 }\r\r
15 \r\r
16 public Word(String word, int score) {\r\r
17 this.word = word;\r\r
18 this.score = score;\r\r
19 }\r\r
20\r\r
21 /** The comparator interface*/\r\r
22 public int compare(Object o1, Object o2) {\r\r
23 if (((Word) o1).getScore() < ((Word) o2).getScore()) return -1;\r\r
24 if (((Word) o1).getScore() == ((Word) o2).getScore()) return 0;\r\r
25 return 1;\r\r
26 }\r\r
27\r\r
28 public String getWord() {\r\r
29 return word;\r\r
30 }\r\r
31\r\r
32 public int getScore() {\r\r
33 return score;\r\r
34 }\r\r
35\r\r
36 public String toString() {\r\r
37 return word;\r\r
38 }\r\r
39}\r\r
40\r\r