inonit.domain.game.card
Class Rank.Order

java.lang.Object
  |
  +--inonit.domain.game.card.Rank.Order
Enclosing class:
Rank

public static class Rank.Order
extends java.lang.Object

A logical ordering for Ranks; can be used to sort arrays of Cards and CardArray objects via the Sort.Orders returned by getAscendingOrder and getDescendingOrder, in conjunction with CardArray's sort method. Different card games have different orderings for Ranks; the two most common are declared as ACE_HIGH and ACE_LOW.


Field Summary
static Rank.Order ACE_HIGH
          An ordering as follows: 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace.
static Rank.Order ACE_LOW
          An ordering as follows: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King.
 
Constructor Summary
Rank.Order(Rank[] ranksInAscendingOrder)
          Creates an ordering of Ranks.
 
Method Summary
 Sort.Order getAscendingOrder()
          Returns a Sort.Order which will sort a set of Cards (not Ranks) into ascending order, as specified by this Rank.Order.
 Sort.Order getDescendingOrder()
          Returns a Sort.Order which will sort a set of Cards (not Ranks) into descending order, as specified by this Rank.Order.
 int getValue(Rank rank)
          Returns the value of a particular Rank in this ordering.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACE_HIGH

public static Rank.Order ACE_HIGH
An ordering as follows: 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace.

ACE_LOW

public static Rank.Order ACE_LOW
An ordering as follows: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King.
Constructor Detail

Rank.Order

public Rank.Order(Rank[] ranksInAscendingOrder)
Creates an ordering of Ranks.
Parameters:
ranksInAscendingOrder - An array containing all the Ranks in this ordering, in ascending order. Must not be null. Must not contain null as any element.
Method Detail

getAscendingOrder

public Sort.Order getAscendingOrder()
Returns a Sort.Order which will sort a set of Cards (not Ranks) into ascending order, as specified by this Rank.Order.
Returns:
A Sort.Order which will sort Cards into ascending order by Rank.

getDescendingOrder

public Sort.Order getDescendingOrder()
Returns a Sort.Order which will sort a set of Cards (not Ranks) into descending order, as specified by this Rank.Order.
Returns:
A Sort.Order which will sort Cards into descending order by Rank.

getValue

public final int getValue(Rank rank)
Returns the value of a particular Rank in this ordering.
Parameters:
rank - The rank for which you wish to obtain the value.
Returns:
An int representing the Rank's value, where 0 represents the lowest value, 1 the second-lowest, etc., or -1 if the given Rank is not included in this ordering.