|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IWordList
Classes implementing IWordList
provide a list of
word-difficulty pairs (Word
objects).
The becker
library contains a file of approximately
4,250 word-difficulty pairs. This file may be opened with the following
code:
import java.io.*; ... InputStream inStream = IWordList.class.getResourceAsStream("words.txt"); Scanner in = new Scanner(new InputStreamReader(inStream));
Alternatively, the file may be downloaded here.
Method Summary | |
---|---|
boolean |
contains(String aWord)
Does the list of words contain a word-difficulty pair with the given word? |
Word |
getWord(IWordPredicate test)
Find one word that passes the given test; the test is typically given by a Hint object (which implements IWordPredicate). |
Word[] |
getWords(int maxDesired,
IWordPredicate test)
Find at most maxDesired words that pass the given test; the test is typically given by a Hint object (which implements IWordPredicate). |
Word[] |
getWords(IWordPredicate test)
Find all the words that pass the given test; the test is typically given by a Hint object (which implements IWordPredicate). |
int |
numWords()
The number of words in the list. |
Word |
randomWord()
Find a random word. |
Word |
randomWord(int difficulty)
Find a random word with the given difficulty in the list. |
Method Detail |
---|
boolean contains(String aWord)
aWord
- a word to search for in the list
int numWords()
Word randomWord()
Word randomWord(int difficulty)
difficulty
- The required difficulty, one of 0..2
Word getWord(IWordPredicate test)
Hint
object (which implements IWordPredicate).
The method should start
with a random word in the list and then proceed sequentially through
the list until it either finds a word that passes the test or it
it exhausts the list, in which case it returns null
.
test
- The test that the Word must pass
null
if no such word exists.Word[] getWords(IWordPredicate test)
Hint
object (which implements IWordPredicate).
test
- The test that each returned Word must pass.
Word[] getWords(int maxDesired, IWordPredicate test)
Hint
object (which implements IWordPredicate).
maxDesired
- the maximum number of words to return.test
- The test that each returned Word must pass.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |