Class WhiteBlackGame

java.lang.Object
  |
  +--WhiteBlackGame
Direct Known Subclasses:
TicTacToeGame

public abstract class WhiteBlackGame
extends java.lang.Object

Tic-Tac-Toe Game:
A WhiteBlackGame object controls the execution of a game that alternates between 2 players called white and black.

Version:
May 18, 2004
Author:
Alyce Brady

Constructor Summary
WhiteBlackGame(Player white, Player black)
          Constructs a game for 2 players, white and black.
 
Method Summary
 Player blackPlayer()
          Returns the player represented by black.
abstract  boolean gameOver()
          Returns true if the game is over; otherwise, returns false.
 edu.kzoo.grid.Grid getGrid()
          Returns the grid in which the game is being played.
 void respondToMousePress(edu.kzoo.grid.Location loc)
          Handles a mouse click on a location of the grid.
 void startGame(edu.kzoo.grid.Grid grid)
          Starts or restarts the game.
 Player whitePlayer()
          Returns the player represented by white.
 boolean whitesTurn()
          Returns true if it is now white's turn; false otherwise.
abstract  boolean whiteWon()
          Returns true if the game is over and white won; false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WhiteBlackGame

public WhiteBlackGame(Player white,
                      Player black)
Constructs a game for 2 players, white and black.

Method Detail

getGrid

public edu.kzoo.grid.Grid getGrid()
Returns the grid in which the game is being played. Will be null until the startGame method is invoked.


whitePlayer

public Player whitePlayer()
Returns the player represented by white.


blackPlayer

public Player blackPlayer()
Returns the player represented by black.


whitesTurn

public boolean whitesTurn()
Returns true if it is now white's turn; false otherwise.


startGame

public void startGame(edu.kzoo.grid.Grid grid)
Starts or restarts the game.


respondToMousePress

public void respondToMousePress(edu.kzoo.grid.Location loc)
Handles a mouse click on a location of the grid.


gameOver

public abstract boolean gameOver()
Returns true if the game is over; otherwise, returns false.


whiteWon

public abstract boolean whiteWon()
Returns true if the game is over and white won; false otherwise.