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 Rank
s; can be used to sort arrays of Card
s and CardArray
objects
via the Sort.Order
s returned by getAscendingOrder
and
getDescendingOrder
, in conjunction with
CardArray's sort
method.
Different card games have different
orderings for Rank
s; 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 Rank s. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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.
Rank.Order
public Rank.Order(Rank[] ranksInAscendingOrder)
- Creates an ordering of
Rank
s.
- Parameters:
ranksInAscendingOrder
- An array containing all the Rank
s in this ordering, in ascending order.
Must not be null
. Must not contain null
as any element.
getAscendingOrder
public Sort.Order getAscendingOrder()
- Returns a
Sort.Order
which will sort a set of Card
s (not Rank
s)
into ascending order, as specified by this Rank.Order
.
- Returns:
- A
Sort.Order
which will sort Card
s into ascending order by Rank
.
getDescendingOrder
public Sort.Order getDescendingOrder()
- Returns a
Sort.Order
which will sort a set of Card
s (not Rank
s)
into descending order, as specified by this Rank.Order
.
- Returns:
- A
Sort.Order
which will sort Card
s 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.