de.kosi.model.game
Class Player

java.lang.Object
  |
  +--de.kosi.model.game.Player

public class Player
extends java.lang.Object

This class represents a player who is either playing a game of Bridge or waiting at a table for three other players to have a game of Bridge together.
In Bridge there are always four players playing a game. Their seatings are called north, east, south, west -- this class provides the constants to refer to these directions.

ChangeLog:

 $Log: Player.java,v $
 Revision 1.3  2001/06/27 11:53:21  betacarotine
 Worked on the Rubber and added comments.

 Revision 1.2  2001/05/30 10:25:51  jiriki
 Refactored Client.

 Revision 1.1.1.1  2001/04/29 18:05:18  jiriki
 Imported sources from zola.

 Revision 1.8  2001/03/15 19:19:48  login
 Worked on GameImpl to make it possible that the declarer plays the dummy's cards
 and prohibit that the dummy does anything.

 Revision 1.7  2001/03/01 20:31:32  wombat
 Worked on table implementation / updated documentation

 Revision 1.6  2001/02/26 11:21:45  wombat
 Worked on table.

 Revision 1.5  2001/02/07 10:28:52  login
 Updated documentation!!!!

 Revision 1.4  2001/02/06 14:37:09  login
 Updated docs

 Revision 1.3  2001/02/06 11:38:48 login
 Updated docs

 

Version:
$Revision: 1.3 $ ($Date: 2001/06/27 11:53:21 $)
Author:
Niklas, Timo, Ole

Field Summary
static java.lang.String[] DIRECTION_STRINGS
          This constant provides english string representations of the directions.
static int EAST
          This constant refers the player seated at east direction.
static int NORTH
          This constant refers the player seated at north direction.
static int NUM_DIRECTIONS
          This constant describes how many directions there are.
static int SOUTH
          This constant refers the player seated at south direction.
static int UNKNOWN
          This constant indicates, that a player has no seat, or the seat is not known.
static int WEST
          This constant refers the player seated at west direction.
 
Constructor Summary
Player(UserImpl user, int direction)
          This constructor creates a new Player instance.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Players are equals, if they are players for the same user.
 int getDirection()
          This method returns the seating direction of this player.
 java.lang.String getName()
          This method returns the player's user name.
 UserImpl getUser()
          This method returns the user assigned to this player.
static int next(int direction)
          Returns the direction next to the given direction.
static int oppositeOf(int direction)
          Returns the direction opposite of the given direction.
static int prev(int direction)
          Returns the direction previous to the given direction.
 void setUser(UserImpl user)
          This method assigns another user with this player.
 java.lang.String toString()
          Returns a string representation of this instance in the form " ()", e.g.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
This constant indicates, that a player has no seat, or the seat is not known.

NORTH

public static final int NORTH
This constant refers the player seated at north direction.

EAST

public static final int EAST
This constant refers the player seated at east direction.

SOUTH

public static final int SOUTH
This constant refers the player seated at south direction.

WEST

public static final int WEST
This constant refers the player seated at west direction.

DIRECTION_STRINGS

public static final java.lang.String[] DIRECTION_STRINGS
This constant provides english string representations of the directions.

NUM_DIRECTIONS

public static final int NUM_DIRECTIONS
This constant describes how many directions there are. These must be four because there are always four players playing a game of Bridge.
Constructor Detail

Player

public Player(UserImpl user,
              int direction)
This constructor creates a new Player instance. The given user will become this player, the direction tells where the player will be seated.
Parameters:
user - The user who wants to play Bridge.
direction - Tells where the player will be seated (this argument must be one of the provided constants NORTH, EAST, SOUTH, WEST)
Throws:
java.lang.IllegalArgumentException - Thrown if the user was null or the direction wasn't one of the constants NORTH, EAST, SOUTH, WEST.
Method Detail

setUser

public void setUser(UserImpl user)
This method assigns another user with this player. This might happen, if a user decides not to finish his game of Bridge because the game will not be cancelled but another user might take his place and finish the game.
Parameters:
user - The new user assigned to this player instance.
Throws:
java.lang.IllegalArgumentException - Thrown if the user argument was null.

getDirection

public int getDirection()
This method returns the seating direction of this player. It is guaranteed, that the result will be one of the constants NORTH, EAST, SOUTH, WEST.
Returns:
The seating direction of this player.

oppositeOf

public static int oppositeOf(int direction)
Returns the direction opposite of the given direction.
Parameters:
direction - The direction to return the opposite of.
Returns:
The direction opposite of the given direction.

next

public static int next(int direction)
Returns the direction next to the given direction.
Parameters:
direction - The direction to return the next of.
Returns:
The direction next to the given direction.

prev

public static int prev(int direction)
Returns the direction previous to the given direction.
Parameters:
direction - The direction to return the previous of.
Returns:
The direction previous to the given direction.

getUser

public UserImpl getUser()
This method returns the user assigned to this player. It is guaranteed that null won't be returned.
Returns:
The user assigned to this player.

toString

public java.lang.String toString()
Returns a string representation of this instance in the form " ()", e.g. "Bill (North)".
Overrides:
toString in class java.lang.Object
Returns:
A string representation of this instance.

getName

public java.lang.String getName()
This method returns the player's user name. Actually it returns the string representation of the user assigned to this player but since that is just the user's (login) name we get the user name.
Returns:
The player's user name.

equals

public boolean equals(java.lang.Object obj)
Players are equals, if they are players for the same user.
Overrides:
equals in class java.lang.Object
Parameters:
obj - Object to compare to.
Returns:
true if obj is equal to this.