de.kosi.model.game
Class SuitBid

java.lang.Object
  |
  +--de.kosi.model.game.Bid
        |
        +--de.kosi.model.game.SuitBid
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class SuitBid
extends Bid
implements java.io.Serializable, java.lang.Comparable

This class represents a suit bid. There are 35 different suit bids possible. Since every possible suit bid instance is needed exactly one time this class provides an array constant which contains all these possible suit bids.
This class implements the Comparable interface to make it possible to decide which suit bid is higher.

ChangeLog:

 $Log: SuitBid.java,v $
 Revision 1.1.1.1  2001/04/29 18:05:18  jiriki
 Imported sources from zola.

 Revision 1.7  2001/03/29 21:01:04  wombat
 - Improved logging.
 - Removed bugs from StressClient

 Revision 1.6  2001/03/21 13:26:36  wombat
 - Removed bugs in Table
 - began implementation of stree client
 - updated documentation

 Revision 1.5  2001/03/18 17:32:04  wombat
 Changed database concept

 Revision 1.4  2001/02/09 19:26:33  login
 Doc-Update

 Revision 1.3  2001/02/07 10:28:53  login
 Updated documentation!!!!

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


 

Version:
$Revision: 1.1.1.1 $ ($Date: 2001/04/29 18:05:18 $)
Author:
Timo, Niklas, Ole
See Also:
Serialized Form

Field Summary
static int NUM_LEVELS
          This constant specifies the total number of bidding levels.
static int NUM_SUIT_BIDS
          This constant specifies the total number of different suit bids.
static int NUM_SUITS
          This constant specifies the number of different suits.
static SuitBid[] SUIT_BIDS
          This array constant stores all possible different SuitBid instances.
static int SUIT_CLUBS
          This constant refers to the clubs suit.
static int SUIT_DIAMONDS
          This constant refers to the diamonds suit.
static int SUIT_HEARTS
          This constant refers to the hearts suit.
static int SUIT_NO_TRUMPS
          This constant refers to the no trumps suit which is actually no suit but we treat it as one to make things easier.
static int SUIT_SPADES
          This constant refers to the spades suit.
static java.lang.String[] SUIT_STRINGS
          String Representation of the suits.
 
Constructor Summary
protected SuitBid()
          Creates a new SuitBid instance with illegal value.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this instance to the given argument.
 boolean equals(java.lang.Object obj)
          Checks whether this instance and the given argument are equal.
 int getLevel()
          Returns the level of this SuitBid instance.
 int getSuit()
          Returns the suit of this SuitBid instance.
static SuitBid getSuitBid(int value)
          This method returns the SuitBid stored in the SUIT_BIDS array constant at the given index.
static SuitBid getSuitBid(int suit, int level)
          This method returns the SuitBid instance with the given suit and level.
 int hashCode()
          Returns a hash code for this SuitBid instance.
 java.lang.String toString()
          Returns a String representation of this bid.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SUIT_STRINGS

public static final java.lang.String[] SUIT_STRINGS
String Representation of the suits.

NUM_SUITS

public static final int NUM_SUITS
This constant specifies the number of different suits. These are spades, hearts, diamonds, clubs and no trumps.

NUM_LEVELS

public static final int NUM_LEVELS
This constant specifies the total number of bidding levels.

NUM_SUIT_BIDS

public static final int NUM_SUIT_BIDS
This constant specifies the total number of different suit bids.

SUIT_NO_TRUMPS

public static final int SUIT_NO_TRUMPS
This constant refers to the no trumps suit which is actually no suit but we treat it as one to make things easier.

SUIT_SPADES

public static final int SUIT_SPADES
This constant refers to the spades suit.

SUIT_HEARTS

public static final int SUIT_HEARTS
This constant refers to the hearts suit.

SUIT_DIAMONDS

public static final int SUIT_DIAMONDS
This constant refers to the diamonds suit.

SUIT_CLUBS

public static final int SUIT_CLUBS
This constant refers to the clubs suit.

SUIT_BIDS

public static SuitBid[] SUIT_BIDS
This array constant stores all possible different SuitBid instances.
Constructor Detail

SuitBid

protected SuitBid()
Creates a new SuitBid instance with illegal value. Needed for Serialization.
Method Detail

getSuitBid

public static SuitBid getSuitBid(int value)
This method returns the SuitBid stored in the SUIT_BIDS array constant at the given index. This index should be equal to the returned SuitBid's internal value.
Parameters:
value - The index to the returned SuitBid.
Returns:
The SuitBid instance at the given internal value.

getSuitBid

public static SuitBid getSuitBid(int suit,
                                 int level)
This method returns the SuitBid instance with the given suit and level.
Parameters:
suit - The suit of the desired SuitBid.
level - The level of the desired SuitBid.
Returns:
The SuitBid with the given suit and level.
Throws:
java.lang.IllegalArgumentException - If the given suit or level were invalid.

getLevel

public int getLevel()
Returns the level of this SuitBid instance.
Returns:
The level of this SuitBid instance.

getSuit

public int getSuit()
Returns the suit of this SuitBid instance.
Returns:
The suit of this SuitBid instance.

equals

public boolean equals(java.lang.Object obj)
Checks whether this instance and the given argument are equal.
Overrides:
equals in class java.lang.Object
Parameters:
obj - The argument to compare to this instance.
Returns:
true if this instance and the given argument are equal, otherwise false.

hashCode

public int hashCode()
Returns a hash code for this SuitBid instance.
Overrides:
hashCode in class java.lang.Object
Returns:
A hash code for this SuitBid instance.

compareTo

public int compareTo(java.lang.Object o)
Compares this instance to the given argument.
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The argument to compare to this instance.
Returns:
A negative number if the argument was greater, zero if the argument and this instance were equal and a positive number if this instance was greater.
Throws:
ClassCastException - If the given argument wasn't an instance of SuitBid.

toString

public java.lang.String toString()
Returns a String representation of this bid.
Overrides:
toString in class java.lang.Object
Returns:
String representation.