Class Rank

java.lang.Object
  |
  +--Rank
All Implemented Interfaces:
java.lang.Comparable

public class Rank
extends java.lang.Object
implements java.lang.Comparable

Specification of the rank values for a standard deck of cards. Client has ability to set either the ace or the king to be the highest ranking card; default is king high. Ranks are established in the following ascending order:

King high: ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king.

Ace high: 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king, ace.

Class can be extended for implementation of speciality decks containing a subset of the standard ranks, e.g. pinochle.


Field Summary
static Rank ACE
          The rank ace.
static Rank EIGHT
          The rank eight.
static Rank FIVE
          The rank five.
static Rank FOUR
          The rank four.
static Rank JACK
          The rank jack.
static Rank KING
          The rank king.
static Rank NINE
          The rank nine.
static Rank QUEEN
          The rank queen.
static Rank SEVEN
          The rank seven.
static Rank SIX
          The rank six.
static Rank TEN
          The rank ten.
static Rank THREE
          The rank three.
static Rank TWO
          The rank two.
static java.util.List VALUES
          List of all rank values.
 
Method Summary
 int compareTo(java.lang.Object otherRankObject)
          Compares the ranks.
 java.lang.String getName()
          Returns a description of this rank.
 java.lang.String getSymbol()
          The symbol associated with this rank.
static void setAceHigh()
          Sets the ace to be the card having highest rank.
static void setKingHigh()
          Sets the king to be the card having highest rank.
 java.lang.String toString()
          Returns a description of this rank.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ACE

public static final Rank ACE
The rank ace.

TWO

public static final Rank TWO
The rank two.

THREE

public static final Rank THREE
The rank three.

FOUR

public static final Rank FOUR
The rank four.

FIVE

public static final Rank FIVE
The rank five.

SIX

public static final Rank SIX
The rank six.

SEVEN

public static final Rank SEVEN
The rank seven.

EIGHT

public static final Rank EIGHT
The rank eight.

NINE

public static final Rank NINE
The rank nine.

TEN

public static final Rank TEN
The rank ten.

JACK

public static final Rank JACK
The rank jack.

QUEEN

public static final Rank QUEEN
The rank queen.

KING

public static final Rank KING
The rank king.

VALUES

public static final java.util.List VALUES
List of all rank values. Used primarily for the purpose of iteration.
Method Detail

setKingHigh

public static void setKingHigh()
Sets the king to be the card having highest rank. The ace is reduced to the lowest rank.

setAceHigh

public static void setAceHigh()
Sets the ace to be the card having highest rank. The two becomes the lowest rank.

getName

public java.lang.String getName()
Returns a description of this rank.
Returns:
the name of this rank.

toString

public java.lang.String toString()
Returns a description of this rank.
Overrides:
toString in class java.lang.Object
Returns:
the name of this rank.

getSymbol

public java.lang.String getSymbol()
The symbol associated with this rank. Returns the symbol, which usually constitutes a single character, in the form of a string. Symbol is used for the construction of the filenames of the card images.
Returns:
string containing the symbol for the rank.

compareTo

public int compareTo(java.lang.Object otherRankObject)
Compares the ranks. Result is dependent on the whether the ace or the king is considered to be the high rank.
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
otherRankObject - the other rank.
Returns:
the arithmetic difference between the compared ranks based on their ordering in the listing of values. This result may differ depending on whether the king or the ace is considered the high card. Result will be < 0 if this rank is lower than the other rank, 0 if the ranks are the same, or > 0 if this rank is higher than the other rank.