|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
Game
public class Game
Game represents the Hangman game control logic. A Game manages the flow of the game and coordinates the operation of the game board and informs the user interface when it should be updated.
Field Summary | |
---|---|
private Board |
gameBoard
the playing area |
private int |
guessCount
The count of wrong guesses |
static int |
kGuessLimit
The limit on number of incorrect guesses allowed. |
private java.lang.String |
secret
The hidden word |
private I_WordSource |
words
the source of secret words. |
Constructor Summary | |
---|---|
Game(Board board,
I_WordSource wordSource)
Construct a Game. |
Method Summary | |
---|---|
boolean |
gameOver()
Determine if the game is over. |
Board |
getBoardCopy()
Return a copy of the board. |
int |
getTurns()
Accessor to turn count. |
boolean |
isLoser()
Determine if the player lost the game (ran out of turns) |
boolean |
isWin()
Determine if the player won the game. |
void |
newGame()
Start a new round of hangman by obtaining a hidden word and giving it to the board. |
void |
processMove(char guess)
Game logic for handling each user guess |
java.lang.String |
solution()
Accessor to the hidden word. |
void |
start()
Start this game. |
Methods inherited from class java.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Board gameBoard
private I_WordSource words
private int guessCount
public static final int kGuessLimit
private java.lang.String secret
Constructor Detail |
---|
public Game(Board board, I_WordSource wordSource)
board
- is the board to be used in this game.wordSource
- is the source of secret words for the game.Method Detail |
---|
public Board getBoardCopy()
public void start()
public void newGame()
public boolean isLoser()
public int getTurns()
public java.lang.String solution()
public void processMove(char guess)
guess
- the letter that was entered by the user.public boolean gameOver()
public boolean isWin()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |