de.kosi.gui.model
Class CCardComparator

java.lang.Object
  |
  +--de.kosi.gui.model.CCardComparator
All Implemented Interfaces:
java.util.Comparator

public class CCardComparator
extends java.lang.Object
implements java.util.Comparator

A class that helps us to sort cards.


Field Summary
protected  int order
          The order of this comparator.
static int ORDER_ASCENDING
          A ascending order.
static int ORDER_DESCENDING
          A descending order.
protected  int[] suitValue
          Four values, one for each suit.
 
Constructor Summary
CCardComparator()
          Creates a new comparator for comparing CCard objects.
 
Method Summary
 int compare(java.lang.Object obj1, java.lang.Object obj2)
          Compares its two CCard arguments for order.
 void setOrder(int order)
          Sets the order of this comparator.
 void setSuitValue(int index, int value)
          Sets the prority value of the suit with the given index.
 void setSuitValues(int clubValue, int diamondValue, int heartValue, int spadeValue)
          Sets the priority values for the four suits.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

ORDER_DESCENDING

public static final int ORDER_DESCENDING
A descending order.

ORDER_ASCENDING

public static final int ORDER_ASCENDING
A ascending order.

order

protected int order
The order of this comparator.

suitValue

protected int[] suitValue
Four values, one for each suit.
Constructor Detail

CCardComparator

public CCardComparator()
Creates a new comparator for comparing CCard objects.
Method Detail

compare

public int compare(java.lang.Object obj1,
                   java.lang.Object obj2)
Compares its two CCard arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
Specified by:
compare in interface java.util.Comparator
Parameters:
obj1 - the first CCard.
obj2 - the second CCard.
Returns:
the order of the two CCard arguments.

setSuitValues

public void setSuitValues(int clubValue,
                          int diamondValue,
                          int heartValue,
                          int spadeValue)
Sets the priority values for the four suits.
Parameters:
clubValue - the value for clubs.
diamondValue - the value for diamonds.
heartValue - the value for hearts.
spadeValue - the value for spades.

setSuitValue

public void setSuitValue(int index,
                         int value)
Sets the prority value of the suit with the given index.
Parameters:
index - the index of the suit.
value - the priority value of the suit.

setOrder

public void setOrder(int order)
Sets the order of this comparator.
Parameters:
order - ORDER_ASCENDING or ORDER_DESCENDING.