|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectBoard
public class Board
Board is the game board in a hangman game. Importantly the board consists of the hidden word, but it also keeps track of which letters have been correctly guessed by the player. Note: Board is not part of the visual display, rather it is the game information itself.
Field Summary | |
---|---|
private java.lang.String |
hiddenWord
The hidden word the player tries to guess |
private int |
kMaxWordLength
|
private java.lang.StringBuffer |
userWord
The "user word" of letters the player has guessed correctly placed in their proper position in the word. |
Constructor Summary | |
---|---|
Board()
Default constructor |
|
Board(Board brd)
Copy constructor returns a copy of the given board. |
Method Summary | |
---|---|
private void |
addLetter(char goodLetter)
Add a correctly guessed letter to user's word. |
private boolean |
contains(char guess)
Determine if the guessed letter is part of the hidden word. |
java.lang.String |
getBoardDisplay()
Format the current state of the board for display. |
(package private) java.lang.String |
getUserWord()
Accessor to user word for testing |
boolean |
isWin()
Determine if the player won (guessed all the letters in the hidden word). |
boolean |
makeMove(char guess)
Process a user guess. |
void |
setHidden(java.lang.String word)
Initialize the hidden word for a game and reset user's word. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String hiddenWord
private final int kMaxWordLength
private java.lang.StringBuffer userWord
Constructor Detail |
---|
public Board()
public Board(Board brd)
brd
- a Board from which we are to construct a copy.Method Detail |
---|
public void setHidden(java.lang.String word)
word
- the hidden word to be used for this game.public boolean makeMove(char guess)
guess
- the letter the player guessed.
private boolean contains(char guess)
guess
- the player's guess
private void addLetter(char goodLetter)
goodLetter
- the player's guess.public boolean isWin()
java.lang.String getUserWord()
public java.lang.String getBoardDisplay()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |