com.threerings.parlor.card.data

## Class Card

- java.lang.Object
- - com.threerings.parlor.card.data.Card

All Implemented Interfaces:
  com.threerings.io.Streamable, CardCodes, com.threerings.presents.data.InvocationCodes, com.threerings.presents.dobj.DSet.Entry, Comparable<Card>

    public class Card
    extends Object
    implements com.threerings.presents.dobj.DSet.Entry, Comparable<Card>, CardCodes

Instances of this class represent individual playing cards.

### Nested Class Summary

### Nested classes/interfaces inherited from interface com.threerings.io.Streamable

`com.threerings.io.Streamable.Closure`

### Field Summary

### Fields inherited from interface com.threerings.parlor.card.data.CardCodes

`ACE, BLACK_JOKER, CLUBS, DIAMONDS, HEARTS, JACK, KING, QUEEN, RED_JOKER, SPADES`

### Fields inherited from interface com.threerings.presents.data.InvocationCodes

`ACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR`

### Constructor Summary

Constructors
Constructor and Description
`Card()` No-arg constructor for deserialization.
`Card(int number, int suit)` Creates a new card.

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `compareTo(Card other)` Compares this card to another.
`boolean` `equals(Object other)`
`Comparable<?>` `getKey()`
`int` `getNumber()` Returns the value of the card, either from 2 to 11 or KING, QUEEN, JACK, ACE, RED_JOKER, or BLACK_JOKER.
`int` `getSuit()` Returns the suit of the card: SPADES, HEARTS, DIAMONDS, or CLUBS.
`int` `hashCode()`
`boolean` `isAce()` Checks whether the card is an ace.
`boolean` `isFace()` Checks whether the card is a face card (KING, QUEEN, or JACK).
`boolean` `isJoker()` Checks whether the card is a joker.
`boolean` `isNumber()` Checks whether the card is a number card (2 to 10).
`boolean` `isValid()` Checks whether or not this card is valid.
`String` `toString()`

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### Card

    public Card()

No-arg constructor for deserialization.

#### Card

    public Card(int number,
                int suit)

Creates a new card.

Parameters:
  `number` - the number of the card
  `suit` - the suit of the card

### Method Detail

#### getNumber

    public int getNumber()

Returns the value of the card, either from 2 to 11 or KING, QUEEN, JACK, ACE, RED_JOKER, or BLACK_JOKER.

Returns:
  the value of the card

#### getSuit

    public int getSuit()

Returns the suit of the card: SPADES, HEARTS, DIAMONDS, or CLUBS. If the card is the joker, the suit is undefined.

Returns:
  the suit of the card

#### isNumber

    public boolean isNumber()

Checks whether the card is a number card (2 to 10).

Returns:
  true if the card is a number card, false otherwise

#### isFace

    public boolean isFace()

Checks whether the card is a face card (KING, QUEEN, or JACK).

Returns:
  true if the card is a face card, false otherwise

#### isAce

    public boolean isAce()

Checks whether the card is an ace.

Returns:
  true if the card is an ace, false otherwise

#### isJoker

    public boolean isJoker()

Checks whether the card is a joker.

Returns:
  true if the card is a joker, false otherwise

#### isValid

    public boolean isValid()

Checks whether or not this card is valid. The no-arg public constructor for deserialization creates an invalid card.

Returns:
  true if this card is valid, false if not

#### getKey

    public Comparable<?> getKey()

Specified by:
  `getKey` in interface `com.threerings.presents.dobj.DSet.Entry`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### equals

    public boolean equals(Object other)

Overrides:
  `equals` in class `Object`

#### compareTo

    public int compareTo(Card other)

Compares this card to another. The card order is the same as the initial deck ordering: two through ten, jack, queen, king, ace for spades, hearts, clubs, and diamonds, then the red joker and the black joker.

Specified by:
  `compareTo` in interface `Comparable<Card>`
Parameters:
  `other` - the other card to compare this to
Returns:
  -1, 0, or +1, depending on whether this card is less than, equal to, or greater than the other card

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`