Class Wordlist

java.lang.Object
  extended by Wordlist
All Implemented Interfaces:
I_WordSource

public class Wordlist
extends java.lang.Object
implements I_WordSource

Wordlist is a list of words to use in Hangman. It can return a single secret word upon request.


Field Summary
private  int current
          Current position in list
static java.lang.String kWordFile
          The name of the file containing words.
private  java.util.List<java.lang.String> list
          the list of words
private  boolean sequential
          retrieve words in order? (for testing)
 
Constructor Summary
Wordlist(boolean order)
          Construct a word list to be accessed either sequentially (for testing) or randomly.
 
Method Summary
 java.lang.String getSecretWord()
          Obtain a secret word from the word list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kWordFile

public static final java.lang.String kWordFile
The name of the file containing words.

See Also:
Constant Field Values

list

private java.util.List<java.lang.String> list
the list of words


current

private int current
Current position in list


sequential

private boolean sequential
retrieve words in order? (for testing)

Constructor Detail

Wordlist

public Wordlist(boolean order)
Construct a word list to be accessed either sequentially (for testing) or randomly. The word list is created from the words in the word file.

Parameters:
order - true for sequential, false for random.
Postcondition:
word list is filled with words from the file, current position in list is 0.
Method Detail

getSecretWord

public java.lang.String getSecretWord()
Obtain a secret word from the word list.

Specified by:
getSecretWord in interface I_WordSource
Returns:
String the word which the player tries to guess