|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectbecker.xtras.jotto.SampleWordList
public final class SampleWordList
A list of words that can grow as needed.
| Constructor Summary | |
|---|---|
SampleWordList()
Create an word list by reading from the file included in the becker library. |
|
SampleWordList(Scanner in)
Create a word list from a file. |
|
| Method Summary | |
|---|---|
void |
add(Word wd)
Add a new word to the list. |
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). |
static void |
main(String[] args)
Test the class. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SampleWordList(Scanner in)
public SampleWordList()
| Method Detail |
|---|
public void add(Word wd)
public boolean contains(String aWord)
IWordList
contains in interface IWordListaWord - a word to search for in the list
public int numWords()
IWordList
numWords in interface IWordListpublic Word randomWord()
IWordList
randomWord in interface IWordListpublic Word randomWord(int difficulty)
IWordList
randomWord in interface IWordListdifficulty - The required difficulty, one of 0..2
public Word getWord(IWordPredicate test)
IWordListHint 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.
getWord in interface IWordListtest - The test that the Word must pass
null if no such word exists.public Word[] getWords(IWordPredicate test)
IWordListHint object (which implements IWordPredicate).
getWords in interface IWordListtest - The test that each returned Word must pass.
public Word[] getWords(int maxDesired,
IWordPredicate test)
IWordListHint object (which implements IWordPredicate).
getWords in interface IWordListmaxDesired - the maximum number of words to return.test - The test that each returned Word must pass.
public static void main(String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||