pictionary
Class PictionaryPlayer

java.lang.Object
  extended by pictionary.PictionaryPlayer
Direct Known Subclasses:
PictionaryServer.ClientConnection

public abstract class PictionaryPlayer
extends java.lang.Object

This abstract class serves as a foundation for a Pictionary player.
It has methods which enables a PictionaryGame to interact with it.

Author:
Kristoffer Nordkvist

Field Summary
static int DRAWING
          The player is drawing.
private  int score
          The player's score.
static int SPECTATING
          The playing is in the game, but not yet playing.
private  int status
          The players current status.
static int WAITING_FOR_TURN
          The player is waiting for his turn.
 
Constructor Summary
PictionaryPlayer(int score, int status)
          The constructor.
 
Method Summary
abstract  void correctGuess(java.lang.String guess)
          Informs the player that he made a correct guess.
abstract  void correctGuessBroadcast(java.lang.String guessingPlayer, java.lang.String word)
          Informs the player that a player made a correct guess.
 boolean equals(java.lang.Object obj)
          This method uses String's String.equals(Object) to compare the value of this player's getClientID() with the other player's getClientID().
abstract  void gameStarted()
          Informs the player that a new game of Pictionary has started.
abstract  java.lang.String getClientID()
          Gets the player's ID.
 int getScore()
          Gets the players score.
 int getStatus()
          Gets the players status.
abstract  void playerStartedDrawing(java.lang.String player)
          Informs the player that a player started drawing.
abstract  void playerStoppedDrawing(java.lang.String player)
          Informs the player that a player stopped drawing.
abstract  void reportScores(java.util.List<java.lang.String> players, java.util.List<java.lang.Integer> scores)
          Reports the players' scores.
 void setScore(int score)
          Set this player's score.
 void setStatus(int status)
          Sets this player's status.
abstract  void startDraw(java.lang.String wordToDraw)
          Informs the player that it is her turn to start drawing a word.
abstract  void startGuessing()
          Informs the player that it can start guessing on the word being drawn.
abstract  void stopDraw()
          Informs the player that its draw turn is over.
abstract  void stopGuessing()
          Informs the player that the guessing turn is over.
abstract  void tellWord(java.lang.String currentWord)
          Tells the player the last word.
abstract  void wrongGuess(java.lang.String player, java.lang.String guess)
          Informs the player that someone made an incorrect guess.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WAITING_FOR_TURN

public static final int WAITING_FOR_TURN
The player is waiting for his turn.

See Also:
Constant Field Values

DRAWING

public static final int DRAWING
The player is drawing.

See Also:
Constant Field Values

SPECTATING

public static final int SPECTATING
The playing is in the game, but not yet playing.

See Also:
Constant Field Values

score

private int score
The player's score.


status

private int status
The players current status.
The value equals one of the static status integers, for example WAITING_FOR_TURN.

Constructor Detail

PictionaryPlayer

public PictionaryPlayer(int score,
                        int status)
The constructor.

Parameters:
score - The player's score.
status - The player's status.
Method Detail

equals

public boolean equals(java.lang.Object obj)
This method uses String's String.equals(Object) to compare the value of this player's getClientID() with the other player's getClientID().

Overrides:
equals in class java.lang.Object

setScore

public void setScore(int score)
Set this player's score.

Parameters:
score - The new score.

setStatus

public void setStatus(int status)
Sets this player's status.

Parameters:
status - The new status.

getScore

public int getScore()
Gets the players score.

Returns:
The player's score.

getStatus

public int getStatus()
Gets the players status.

Returns:
The player's status.

playerStoppedDrawing

public abstract void playerStoppedDrawing(java.lang.String player)
Informs the player that a player stopped drawing.

Parameters:
player - The name of the player that stopped drawing.

stopDraw

public abstract void stopDraw()
Informs the player that its draw turn is over.


playerStartedDrawing

public abstract void playerStartedDrawing(java.lang.String player)
Informs the player that a player started drawing.

Parameters:
player - The name of the player that started drawing.

startDraw

public abstract void startDraw(java.lang.String wordToDraw)
Informs the player that it is her turn to start drawing a word.

Parameters:
wordToDraw - The word that the player should attempt to draw.

startGuessing

public abstract void startGuessing()
Informs the player that it can start guessing on the word being drawn.


gameStarted

public abstract void gameStarted()
Informs the player that a new game of Pictionary has started.


correctGuess

public abstract void correctGuess(java.lang.String guess)
Informs the player that he made a correct guess.

Parameters:
guess - The guess that was correct.

correctGuessBroadcast

public abstract void correctGuessBroadcast(java.lang.String guessingPlayer,
                                           java.lang.String word)
Informs the player that a player made a correct guess.

Parameters:
guessingPlayer - The player that made the guess.
word - The correct word.

getClientID

public abstract java.lang.String getClientID()
Gets the player's ID.

Returns:
The player's ID.

reportScores

public abstract void reportScores(java.util.List<java.lang.String> players,
                                  java.util.List<java.lang.Integer> scores)
Reports the players' scores.
A score at a specific index in scores corresponds to the player at the same index in players.

Parameters:
players - A collection of players.
scores - A collection of scores.

stopGuessing

public abstract void stopGuessing()
Informs the player that the guessing turn is over.


wrongGuess

public abstract void wrongGuess(java.lang.String player,
                                java.lang.String guess)
Informs the player that someone made an incorrect guess.

Parameters:
player - The player that made the guess.
guess - The incorrect guess.

tellWord

public abstract void tellWord(java.lang.String currentWord)
Tells the player the last word. This method is used when no one makes a correct guess.

Parameters:
currentWord - The word that was being drawn.