checkers.controller
Class GameController

java.lang.Object
  extended by checkers.controller.GameController
All Implemented Interfaces:
CheckersConstants, java.awt.event.ActionListener, java.awt.event.WindowListener, java.util.EventListener

public class GameController
extends java.lang.Object
implements java.awt.event.ActionListener, CheckersConstants, java.awt.event.WindowListener

An interface between the GUI and the kernel classes in a checkers game.

Author:

Field Summary
 
Fields inherited from interface checkers.CheckersConstants
ACCEPT, BLUE, CLIENTGAME, DRAW, HOST, HOSTGAME, JOIN, KING, LOCAL, LOCALGAME, NUM_SPACES, PLAYER1SET, PLAYER2SET, RESIGN, SINGLE, UPDATE, WHITE
 
Constructor Summary
GameController(CheckersGame game)
          Creates the controller with a reference to the game.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Handles events
 void endGameAccepted()
          Called when both players have clicked OK on the end game dialog box
 void pressAcceptDraw()
          Tell the model that the user has accepted a draw.
 void pressDraw()
          Tell the model that the user has requested a draw.
 void pressQuit()
          Tell the kernel that the user has quit/resigned the game or quit the program
 void selectSpace(int space)
          This method should be called to select a space on the board, either as the starting point or the ending point for a move.
 void setPlayer(int playerNum)
          Sets the playerNum for a networked game.
 void setPlayerName(int playerNum, java.lang.String name)
          Tell the model to associate the given name with the given player number.
 void showEndGame(java.lang.String message)
          Display to local players that the game has ended with the message provided.
 void startGame()
          Begin the game
 void windowActivated(java.awt.event.WindowEvent arg0)
           
 void windowClosed(java.awt.event.WindowEvent arg0)
           
 void windowClosing(java.awt.event.WindowEvent arg0)
          Called when the user tries to exit the program.
 void windowDeactivated(java.awt.event.WindowEvent arg0)
           
 void windowDeiconified(java.awt.event.WindowEvent arg0)
           
 void windowIconified(java.awt.event.WindowEvent arg0)
           
 void windowOpened(java.awt.event.WindowEvent arg0)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GameController

public GameController(CheckersGame game)
Creates the controller with a reference to the game.

Parameters:
game - CheckersGame
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Handles events

Specified by:
actionPerformed in interface java.awt.event.ActionListener

selectSpace

public void selectSpace(int space)
This method should be called to select a space on the board, either as the starting point or the ending point for a move. Forwards the request to game.

Parameters:
space - an int indicating which space to move to, according to the standard checkers numbering scheme, left to right and top to bottom.

pressQuit

public void pressQuit()
Tell the kernel that the user has quit/resigned the game or quit the program


pressDraw

public void pressDraw()
Tell the model that the user has requested a draw.


pressAcceptDraw

public void pressAcceptDraw()
Tell the model that the user has accepted a draw.


setPlayerName

public void setPlayerName(int playerNum,
                          java.lang.String name)
Tell the model to associate the given name with the given player number.

Parameters:
playerNum - the number of a player
name - the name that player should be given

showEndGame

public void showEndGame(java.lang.String message)
Display to local players that the game has ended with the message provided.

Parameters:
message -

endGameAccepted

public void endGameAccepted()
Called when both players have clicked OK on the end game dialog box


startGame

public void startGame()
Begin the game


setPlayer

public void setPlayer(int playerNum)
Sets the playerNum for a networked game. (so that you can't move the other player's pieces)

Parameters:
playerNum - number of player

windowClosing

public void windowClosing(java.awt.event.WindowEvent arg0)
Called when the user tries to exit the program.

Specified by:
windowClosing in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent arg0)
Specified by:
windowOpened in interface java.awt.event.WindowListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent arg0)
Specified by:
windowClosed in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent arg0)
Specified by:
windowIconified in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent arg0)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent arg0)
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent arg0)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener