|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.kosi.model.game.Players
This class handles the four players who are playing the same game of Bridge. Since there are always four players palying one game this class provides the constant NUM_PLAYERS which is set to four. Each player gets a seating assigned to him and one of the players will be the so called opener who is the player who starts the bidding sequence which is the first phase in a game of Bridge.
ChangeLog:
$Log: Players.java,v $ Revision 1.5 2001/07/20 14:37:08 jiriki Fixed Bug 440605 Revision 1.4 2001/05/30 10:19:18 pizarro Updated Documentation. Revision 1.3 2001/05/09 17:29:41 betacarotine Removed a bug in getDirection Revision 1.2 2001/05/09 11:44:40 betacarotine The Table interface got a getDirection method that returns the direction of the calling user. Revision 1.1.1.1 2001/04/29 18:05:18 jiriki Imported sources from zola. Revision 1.9 2001/03/05 20:55:22 login - Game (und zugehoerige Klassen) soweit fertig - package de.kosi.model.tournament angelegt - Pair angelegt - Round angelegt - Movement-Interface angelegt - KosiMovement fertig!!! :-) - KosiMovementTest um das KosiMovement zu testen (kann mit KOSI/kosimovementtestaufgerufen werden) - Tournament und TournamentImpl in das package de.kosi.model.tournament verschoben - buildfile fuer die neuen klassen angepasst Revision 1.8 2001/03/01 20:31:32 wombat Worked on table implementation / updated documentation Revision 1.7 2001/02/26 11:21:45 wombat Worked on table. Revision 1.6 2001/02/21 11:38:47 wombat Worked on GameImpl and Board Revision 1.5 2001/02/09 19:26:33 login Doc-Update Revision 1.4 2001/02/07 10:28:52 login Updated documentation!!!! Revision 1.3 2001/02/06 14:37:09 login Updated docs
Field Summary | |
static int |
NUM_PLAYERS
Since there are always exactly four players needed to play a game of Bridge this class provides this constant. |
Constructor Summary | |
Players()
This constructor creates a new Players instance with no players. |
|
Players(Pair northSouth,
Pair eastWest)
This constructor creates a new Players instance with the given pairs as players. |
|
Players(UserImpl north,
UserImpl east,
UserImpl south,
UserImpl west)
This constructor creates a new Players instance with the specified users as players and the specified opener direction. |
Method Summary | |
boolean |
contains(Player player)
This method checks whether the given player is part of this Players instance. |
boolean |
contains(User user)
|
int |
getDirection(User user)
Returns the direction of the given user |
int |
getDistance(Player from,
Player to)
This method returns the distance between the two given players. |
Player |
getPlayer(int direction)
Returns the Player who is seated at the specified direction or null if there is no player seated yet. |
java.lang.String[] |
getPlayerNames()
Returns all player names of this Players instance as array. |
Player[] |
getPlayers()
Returns all players of this Players instance as array. |
boolean |
readyToPlay()
Returns whether this Players instance contains enough information to start playing. |
void |
removePlayer(int direction)
Removes the player at the given direction. |
void |
removePlayer(Player player)
Removes the given player from this Players instance, e.g. when he left the game. |
void |
setPlayer(Player player)
Seats the given player at the direction stored in his own direction attribute. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int NUM_PLAYERS
Constructor Detail |
public Players()
java.lang.IllegalArgumentException
- If a not existing direction was given.public Players(Pair northSouth, Pair eastWest)
northSouth
- The pair seated north-south.eastWest
- The pair seated east-west.public Players(UserImpl north, UserImpl east, UserImpl south, UserImpl west)
north
- The user assigned to the player seated at north.east
- The user assigned to the player seated at east.south
- The user assigned to the player seated at south.west
- The user assigned to the player seated at west.Method Detail |
public boolean contains(Player player)
player
- The player of whom we want to find out whether he
is part of this Players instance.public boolean contains(User user)
public int getDistance(Player from, Player to)
from
- The player from which we want to measure the
distance.to
- The player to which we want to measure the distance.java.lang.IllegalArgumentException
- If one of the given players
is not part of this Players instance.public Player getPlayer(int direction)
direction
- The direction of the player we are interested
in. Must be one of the constants Player.NORTH, Player.EAST,
Player.SOUTH, Player.WEST.ArrayIndexOutOfBoundsException
- If the given direction
was illegal.public void removePlayer(int direction)
direction
- The direction of the player who left the
game. Must be one of the constants Player.NORTH, Player.EAST,
Player.SOUTH, Player.WEST.ArrayIndexOutOfBoundsException
- If the direction was
invalid.public void removePlayer(Player player)
player
- The player to remove from this Players instance.java.lang.IllegalArgumentException
- If the given player wasn't
part of this players instance.public void setPlayer(Player player)
player
- The new player.public Player[] getPlayers()
public java.lang.String[] getPlayerNames()
public boolean readyToPlay()
public int getDirection(User user) throws java.lang.IllegalArgumentException
user
- The user whose direction should be returned.java.lang.IllegalArgumentException
- If the user isn't contained
by the players object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |