de.kosi.model
Class Rubber

java.lang.Object
  |
  +--de.kosi.model.Rubber
All Implemented Interfaces:
java.io.Serializable

public class Rubber
extends java.lang.Object
implements java.io.Serializable

This class provides mechanisms for rubber-scoring.

ChangeLog:

 $Log: Rubber.java,v $
 Revision 1.3  2001/07/04 12:17:12  uid51247
 now the rubber valuations are available to the clients

 Revision 1.2  2001/06/27 11:53:20  betacarotine
 Worked on the Rubber and added comments.

 Revision 1.1  2001/06/22 14:16:51  betacarotine
 Startet implementing a rubber valuation


 

Version:
$Revision: 1.3 $ ($Date: 2001/07/04 12:17:12 $)
Author:
PG KoSI, Fachbereich Informatik, Universitaet Oldenburg
See Also:
Serialized Form

Field Summary
static int EAST_WEST
          This constant refers the pair seated at east/west direction.
static int NORTH_SOUTH
          This constant refers the pair seated at north/south direction.
static int NUM_GAMES
          The maximum number of games in a rubber.
static int NUM_PAIRS
          The number of pairs playing a rubber.
 
Constructor Summary
Rubber()
          Creates a new rubber.
Rubber(Result result)
           
 
Method Summary
 int gamesWonBy(int pair)
          Returns the number of games that were won by the given pair.
 int getCurrentGame()
          Returns the current game in a rubber.
 int getGameScore(int pair, int game)
          Returns the score in a rubber for the given pair in the given game.
 int getLoser()
           
 int getPointsAbove(int pair)
          Returns the points above the line in a rubber for the given pair.
 int getTotal(int pair)
          Returns the total points in a rubber for the given pair.
 int getWinner()
           
 boolean isFinished()
          Returns whether the rubber is over or not.
 void update(Result result)
          Updates the points above and below the line with the given result for both pairs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_GAMES

public static final int NUM_GAMES
The maximum number of games in a rubber.

NUM_PAIRS

public static final int NUM_PAIRS
The number of pairs playing a rubber.

NORTH_SOUTH

public static final int NORTH_SOUTH
This constant refers the pair seated at north/south direction.

EAST_WEST

public static final int EAST_WEST
This constant refers the pair seated at east/west direction.
Constructor Detail

Rubber

public Rubber()
Creates a new rubber.

Rubber

public Rubber(Result result)
Method Detail

gamesWonBy

public int gamesWonBy(int pair)
Returns the number of games that were won by the given pair.
Parameters:
pair - The pair of which the number of won games is to be returned.
Throws:
java.lang.IllegalArgumentException - If the given argument was no pair constant.

getCurrentGame

public int getCurrentGame()
                   throws RubberException
Returns the current game in a rubber.
Returns:
The current game in a rubber.
Throws:
RubberException - If the Rubber is already over.

getPointsAbove

public int getPointsAbove(int pair)
Returns the points above the line in a rubber for the given pair.
Parameters:
pair - The pair from which to return the points above the line.
Returns:
The points above the line for the given pair.
Throws:
ArrayIndexOutOfBoundsException - If the given index was invalid.

getTotal

public int getTotal(int pair)
Returns the total points in a rubber for the given pair.
Parameters:
pair - The pair from which to return the total points.
Returns:
The total points for the given pair.

getGameScore

public int getGameScore(int pair,
                        int game)
Returns the score in a rubber for the given pair in the given game.
Parameters:
pair - The pair from which to return the score in the given game.
game - The game from which to return the score for the given pair.
Returns:
The score in a rubber for the given pair in the given game.
Throws:
ArrayIndexOutOfBoundsException - If the given index was invalid.

getWinner

public int getWinner()
              throws RubberException

getLoser

public int getLoser()
             throws RubberException

update

public void update(Result result)
            throws RubberException
Updates the points above and below the line with the given result for both pairs.
Parameters:
result - The result to add to the rubber.
Throws:
RubberException - If the Rubber is already over.

isFinished

public boolean isFinished()
Returns whether the rubber is over or not.
Returns:
true if the rubber is over else false.