Class Controller

java.lang.Object
  extended by Controller
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class Controller
extends java.lang.Object
implements java.awt.event.ActionListener

Controller handles user events in the UI.

Author:
jdalbey

Field Summary
private  Game game
          Reference to the game we are controlling
private  HangmanUI view
          Reference to the view we are responding to
 
Constructor Summary
Controller(HangmanUI view)
          Construct a controller to respond to the specified view
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Handle a button press by the user.
 void handlePlayAgainChoice(int choice)
          Handle the user's choice for playing again (yes/no)
 void setGame(Game game)
          Set the reference to the game we are controlling
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

game

private Game game
Reference to the game we are controlling


view

private HangmanUI view
Reference to the view we are responding to

Constructor Detail

Controller

public Controller(HangmanUI view)
Construct a controller to respond to the specified view

Parameters:
view - The view this controller responds to
Method Detail

setGame

public void setGame(Game game)
Set the reference to the game we are controlling

Parameters:
game - the game to be controlled.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Handle a button press by the user. Determine which letter was chosen.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - Event to be dispatched

handlePlayAgainChoice

public void handlePlayAgainChoice(int choice)
Handle the user's choice for playing again (yes/no)

Parameters:
choice - JOptionPane.YES_OPTION=new game, JOptionPane.NO_OPTION=exit