java.lang.Object | +--SimpleUI
Default User interface for the Hangman game. Provides a console-based user interface. Obtains user guesses from the keyboard and displays a very simplistic view of the board.
| Field Summary | |
protected Board |
board
the playing board |
private java.io.BufferedReader |
in
input stream for the keyboard |
private HangmanLogic |
parent
the instance of game logic that will call us |
| Constructor Summary | |
SimpleUI()
Display a welcome message |
|
| Method Summary | |
void |
display()
Make the interface visible |
private char |
getMove()
Asks the user for a move until the user enters a move that is valid. |
void |
playAgain()
Handle end of game, asking if the player wants another game If yes, start a new game, otherwise exit. |
void |
setBoard(Board theBoard)
Save a reference to the instance of the Board. |
void |
setParent(HangmanLogic theParent)
Save a reference to the parent (an instance of HangmanLogic) |
void |
showBoard()
Display the current state of the board. |
void |
showLose()
Display that the player lost the game. |
void |
showWin()
Display that the player won the game. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Board board
private java.io.BufferedReader in
private HangmanLogic parent
| Constructor Detail |
public SimpleUI()
| Method Detail |
public void display()
display in interface HangmanUI
private char getMove()
throws java.lang.Exception
java.lang.Exceptionpublic void playAgain()
playAgain in interface HangmanUIpublic void setBoard(Board theBoard)
setBoard in interface HangmanUIpublic void setParent(HangmanLogic theParent)
setParent in interface HangmanUIpublic void showBoard()
showBoard in interface HangmanUIpublic void showLose()
showLose in interface HangmanUIpublic void showWin()
showWin in interface HangmanUI