proj3
Class Rank

java.lang.Object
  extended by proj3.Rank
All Implemented Interfaces:
java.lang.Comparable<Rank>

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

The Rank class defines each of the 13 ranks of a standard deck of playing cards. Using this class assures that all code refers to the ranks in the same manner. i.e Rank.ACE, Rank.TWO, ... Rank.QUEEN, Rank.KING with no possibility of conflicting representations.

Class Invariant:
The Rank's symbol is a single alpha-numeric character
The Ranks's name is a non-empty string
14 <= Rank's value <= 2 and unique
Rank objects are immutable and unique

Author:
Dennis Frey

Field Summary
static Rank ACE
           
static Rank EIGHT
           
static Rank FIVE
           
static Rank FOUR
           
static Rank JACK
           
static Rank KING
           
static Rank NINE
           
static Rank QUEEN
           
static Rank SEVEN
           
static Rank SIX
           
static Rank TEN
           
static Rank THREE
           
static Rank TWO
           
 
Method Summary
 int compareTo(Rank r)
          Compares two ranks
returns negative if the calling object's rank less than the parameter's
returns positive if the calling object's rank is greater than the parameter's
returns 0 if the ranks are the same
 boolean equals(java.lang.Object obj)
          Determines if two Rank objects are equal
 java.lang.String getName()
          Accessor for the Rank's name
 java.lang.String getSymbol()
          Accessor the Rank's symbol
static Rank[] VALUES()
          VALUES A static method to return all ranks
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACE

public static final Rank ACE

TWO

public static final Rank TWO

THREE

public static final Rank THREE

FOUR

public static final Rank FOUR

FIVE

public static final Rank FIVE

SIX

public static final Rank SIX

SEVEN

public static final Rank SEVEN

EIGHT

public static final Rank EIGHT

NINE

public static final Rank NINE

TEN

public static final Rank TEN

JACK

public static final Rank JACK

QUEEN

public static final Rank QUEEN

KING

public static final Rank KING
Method Detail

VALUES

public static Rank[] VALUES()
VALUES A static method to return all ranks

Returns:
an array of Rank objects suitable for looping

getSymbol

public java.lang.String getSymbol()
Accessor the Rank's symbol

Returns:
the 1-char symbol as a String

getName

public java.lang.String getName()
Accessor for the Rank's name

Returns:
the rank's name as a String

equals

public boolean equals(java.lang.Object obj)
Determines if two Rank objects are equal

Overrides:
equals in class java.lang.Object
Parameters:
obj - to be compared with
Returns:
true if equal, false if not

compareTo

public int compareTo(Rank r)
Compares two ranks
returns negative if the calling object's rank less than the parameter's
returns positive if the calling object's rank is greater than the parameter's
returns 0 if the ranks are the same

Specified by:
compareTo in interface java.lang.Comparable<Rank>
Parameters:
r - is the other rank that is compared