Class Player

java.lang.Object
  extended by Player
Direct Known Subclasses:
LocalPlayer, NetworkPlayer

public abstract class Player
extends java.lang.Object

A class representation of the Player object. This object contains the methods needed when one of the users clicks on one of the buttons within the GUI.

Author:

Field Summary
static int LOCALPLAYER
           
static int NETWORKPLAYER
           
 
Constructor Summary
Player(int num, Rules newRules, Driver newDriver)
          Create a new instance of a Player object to represent one of the users.
 
Method Summary
abstract  void acceptDraw(Player player)
          When the current player accepts a draw, this method is called in the opposite player to inform them that the draw has been accepted.
abstract  void endInDeclineDraw(Player player)
          Method is invoked if the other player declines a draw.
abstract  void endInDraw(Player player)
          Method that is invoked when the end of game conditions have been met.
abstract  void endOfGame(java.lang.String message)
          This method is used for when a user has clicked on the "Quit" button on the GUI.
 java.awt.Color getColor()
          Return the color of this player
 java.lang.String getName()
          Returns the players name
 int getNumber()
          Returns the number for this player
 int getType()
          Return the type of player.
 boolean makeMove(int start, int end)
          Make an istance of a Move that was just made and pass it to theRules by calling its validateMove method.
abstract  void offerDraw(Player player)
          When the current player clicks the draw button, this method is called in the opposite player to inform them that a draw has been offered.
 void setColor(java.awt.Color newColor)
          Set the color for this player.
 void setName(java.lang.String name)
          Sets the players name
 java.lang.String toString()
          A string representation of this object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCALPLAYER

public static int LOCALPLAYER

NETWORKPLAYER

public static int NETWORKPLAYER
Constructor Detail

Player

public Player(int num,
              Rules newRules,
              Driver newDriver)
Create a new instance of a Player object to represent one of the users.

Parameters:
num - The number of the player.
newRules - The rules used to validate moves.
newDriver - Driver which will control this.
Method Detail

getType

public int getType()
Return the type of player.

Returns:
The type of player.

makeMove

public boolean makeMove(int start,
                        int end)
Make an istance of a Move that was just made and pass it to theRules by calling its validateMove method.

Parameters:
start - The starting spot of the move. The legal squares on the checkers boardare numbered from 1 to 32, left to right, top to bottom.
end - The ending spot of the move.
Returns:
true If move was made, false otherwise

endOfGame

public abstract void endOfGame(java.lang.String message)
This method is used for when a user has clicked on the "Quit" button on the GUI. It handles exiting the game.

Parameters:
the - player who quit

offerDraw

public abstract void offerDraw(Player player)
When the current player clicks the draw button, this method is called in the opposite player to inform them that a draw has been offered. This method is implemented differently for localPlayer and networkPlayer.

Parameters:
the - player who offered the draw

acceptDraw

public abstract void acceptDraw(Player player)
When the current player accepts a draw, this method is called in the opposite player to inform them that the draw has been accepted. This method is implemented differently for localPlayer and networkPlayer.


endInDeclineDraw

public abstract void endInDeclineDraw(Player player)
Method is invoked if the other player declines a draw. It displays the dialog box for the decline of draw


endInDraw

public abstract void endInDraw(Player player)
Method that is invoked when the end of game conditions have been met. If they have been, this method is called in both players to notify them of this with a message. Implementation differs for local player and network player.

Parameters:
endMessage - Message indicating the end of the game.

getNumber

public int getNumber()
Returns the number for this player

Returns:
playerNumber

getName

public java.lang.String getName()
Returns the players name

Returns:
the players name

setName

public void setName(java.lang.String name)
Sets the players name

Parameters:
the - name to be set

getColor

public java.awt.Color getColor()
Return the color of this player

Returns:
the color of this player

setColor

public void setColor(java.awt.Color newColor)
Set the color for this player.

Parameters:
newColor - The new color for this player.

toString

public java.lang.String toString()
A string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this object.