Class Driver

java.lang.Object
  extended by Driver

public class Driver
extends java.lang.Object

This class is a part of the main functionality of the checkers game. This class contains the main method to start the game, it creates all necessary classes as informaton is provided. Its functions include knowing whose turn it is, remembering multiple jumps, relaying end of game conditions and ending the game.

Author:

Constructor Summary
Driver()
          Constructor Create the driver, which in turn creates the rest of the system.
 
Method Summary
 void createPlayer(int num, int type, java.lang.String name)
          This method creates the correct players for a game.
 void declineDraw(Player player)
          The offer for a draw has been made.
 void drawOffered(Player player)
          This method is called if a draw has been offered
 void endGame(java.lang.String message)
          This method ends the checkers game due to whatever reason neccessary ie.
 void endInDraw(Player player)
          This method ends the game in a draw, alerting both players that the draw has taken place
 void endInQuit(Player player)
          Ends the game as a result of a player quitting, notifying each player
 void endTurn(Player player, int space)
          This method is called after a move has been checked.
 Facade getFacade()
          Return the facade the GUI will talk to.
 int getGameMode()
          Return the integer representing the type of game
 Player getOppositePlayer()
          Return the player whos turn it is not
 Notifier getTimerNotifier()
          Return the notifier of the Timer
 void setGameMode(int newMode)
          Select the type of game
 void setHost(java.net.URL host)
          This method sets the host the player will play against in case of a game over a network.
 void setPlayerColor(int num, java.awt.Color color)
          Set the color for a player using the passed in value.
 void setPlayerName(int num, java.lang.String name)
          Set the name for the player using the passed in values.
 void setTimer(int time, int warning)
          This method creates the timer to be used, if one is desired to be used.
 void startGame()
          This method will start the game play.
 boolean timerRunning()
          Whether the current game uses a timer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Driver

public Driver()
Constructor Create the driver, which in turn creates the rest of the system.

Method Detail

getFacade

public Facade getFacade()
Return the facade the GUI will talk to.

Returns:
A facade to talk to the GUI.

endTurn

public void endTurn(Player player,
                    int space)
This method is called after a move has been checked. Changes active player when a final succesful jump has been made, resets the timer when appropriate, and tells the appropriate player whos turn it is to make a move.

Parameters:
player - The player whose turn it will now be
space - The space on the board from which a multiple jump has to be made

endGame

public void endGame(java.lang.String message)
This method ends the checkers game due to whatever reason neccessary ie. a draw, someone quitting, or a victory.

Parameters:
message - the message to send to all players regarding the reason for ending the game

createPlayer

public void createPlayer(int num,
                         int type,
                         java.lang.String name)
This method creates the correct players for a game.

Parameters:
type - the type of player to be created (0 - local, 1 - network)
name - the name of the player
num - the player's number

setPlayerName

public void setPlayerName(int num,
                          java.lang.String name)
Set the name for the player using the passed in values.

Parameters:
num - The player's number (1 or 2)
name - The name to assign to the player.

setPlayerColor

public void setPlayerColor(int num,
                           java.awt.Color color)
Set the color for a player using the passed in value.

Parameters:
num - The player's number (1 or 2)
color - The color to assign to the player.

endInDraw

public void endInDraw(Player player)
This method ends the game in a draw, alerting both players that the draw has taken place


drawOffered

public void drawOffered(Player player)
This method is called if a draw has been offered

Parameters:
the - player who offered the draw

declineDraw

public void declineDraw(Player player)
The offer for a draw has been made. This method declines that offer, meaning the game will continue.

Parameters:
player - The player declining the draw.

endInQuit

public void endInQuit(Player player)
Ends the game as a result of a player quitting, notifying each player

Parameters:
the - player who quit

setTimer

public void setTimer(int time,
                     int warning)
This method creates the timer to be used, if one is desired to be used. It will also set the number of seconds for each turn.

Parameters:
time - : the number of seconds for each turn
warning - : whether or not a player will be warned that their turn is going to end

startGame

public void startGame()
This method will start the game play. Letting the first person move their piece and so on


setHost

public void setHost(java.net.URL host)
This method sets the host the player will play against in case of a game over a network.

Parameters:
host - the host of the game to be played

getOppositePlayer

public Player getOppositePlayer()
Return the player whos turn it is not

Returns:
the player whose turn it is not

timerRunning

public boolean timerRunning()
Whether the current game uses a timer

Returns:
true if a timer is being sed in the game, otherwise false

setGameMode

public void setGameMode(int newMode)
Select the type of game

Parameters:
mode - the mode (0 local, 1 host, 2 client) of the game

getGameMode

public int getGameMode()
Return the integer representing the type of game

Returns:
the type of game

getTimerNotifier

public Notifier getTimerNotifier()
Return the notifier of the Timer

Returns:
the notifier for the Timer