|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectHangmanDictionary
A source of words for the game of Hangman. Words are taken from a textfile, or in case the file is not located or has no suitable words, a short internal list is generated. The method isValidWord(), together with constants defining minimum and maximum lengths, determine which words from the file are considered valid for the game.
Field Summary | |
static int |
MAX_WORD_LENGTH
Longest allowable word. |
static int |
MIN_WORD_LENGTH
Shortest allowable word. |
static java.lang.String |
WORD_DELIMITER
Delimiter (regular expression) for separating words on the input file. |
static java.lang.String |
WORD_MATCH_PATTERN
Pattern (regular expression) used to extract candidate words on the input. |
Constructor Summary | |
HangmanDictionary(java.lang.String fileID)
Create a dictionary of Hangman words from a given file; if the file cannot be opened, a small built-in default set of words is used. |
Method Summary | |
java.lang.String |
chooseWord()
Pick a word which hasn't been chosen recently. |
static boolean |
isLegalWord(java.lang.String word)
Determine if the given string is a valid word for the game. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int MIN_WORD_LENGTH
public static final int MAX_WORD_LENGTH
public static final java.lang.String WORD_DELIMITER
public static final java.lang.String WORD_MATCH_PATTERN
Constructor Detail |
public HangmanDictionary(java.lang.String fileID)
fileID
- identifier of a file containing suitable words
for Hangman.Method Detail |
public java.lang.String chooseWord()
chooseWord
in interface IHangmanDictionary
IHangmanDictionary.chooseWord()
public static boolean isLegalWord(java.lang.String word)
word
- any string
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |