Class SimpleUI

java.lang.Object
  |
  +--SimpleUI
All Implemented Interfaces:
HangmanUI

public class SimpleUI
extends java.lang.Object
implements HangmanUI

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

board

protected Board board
the playing board


in

private java.io.BufferedReader in
input stream for the keyboard


parent

private HangmanLogic parent
the instance of game logic that will call us

Constructor Detail

SimpleUI

public SimpleUI()
Display a welcome message

Method Detail

display

public void display()
Make the interface visible

Specified by:
display in interface HangmanUI

getMove

private char getMove()
              throws java.lang.Exception
Asks the user for a move until the user enters a move that is valid.

java.lang.Exception

playAgain

public void playAgain()
Handle end of game, asking if the player wants another game If yes, start a new game, otherwise exit.

Specified by:
playAgain in interface HangmanUI

setBoard

public void setBoard(Board theBoard)
Save a reference to the instance of the Board.

Specified by:
setBoard in interface HangmanUI

setParent

public void setParent(HangmanLogic theParent)
Save a reference to the parent (an instance of HangmanLogic)

Specified by:
setParent in interface HangmanUI

showBoard

public void showBoard()
Display the current state of the board. Specifically, display the turn counter and display the board in some formatted manner.

Specified by:
showBoard in interface HangmanUI

showLose

public void showLose()
Display that the player lost the game. Reveal the solution.

Specified by:
showLose in interface HangmanUI

showWin

public void showWin()
Display that the player won the game.

Specified by:
showWin in interface HangmanUI