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.Exception
public void playAgain()
playAgain
in interface HangmanUI
public void setBoard(Board theBoard)
setBoard
in interface HangmanUI
public void setParent(HangmanLogic theParent)
setParent
in interface HangmanUI
public void showBoard()
showBoard
in interface HangmanUI
public void showLose()
showLose
in interface HangmanUI
public void showWin()
showWin
in interface HangmanUI