solitaire
Interface IGuiCard
- All Known Implementing Classes:
- GuiCard, GuiCardProxy
public interface IGuiCard
This interface must be implemented by cards that will be used in the
Solitaire package. There are only two methods required for a card class to be
used in the GUI Solitaire package: one that provides a card's ID, and one
that indicates whether a card is face up.
The interface method getCardID
must be implemented to return a
lower-case string such as "as", "ah", "ac", "ad", ... "4h", "5h", and so on
where the rank is the first character and it's one of "a23456789tjqk"
and the suit is a single character from "shcd"
.
To facilitate returning appropriate IDs, implementers are urged to use this
interface's constant String arrays for accessing appropriate strings, e.g.,
IGuiCard.rankPrefixes[0]
returns the appropriate string for an
ace -- "a" and IGuiCard.rankPrefixes[12]
returns the
appropriate string for a king -- "k".
Note that for accessing these constants, "ace" is 0, "two" is 1, and "king"
is 12. However, the actual rank of a card representing an ace can be 14 or 1
or any number, e.g., when returned by a card's getRank
method
if there is such a method. The two methods in this interface are used in the
GUI, but not as part of any game (though they could be so used).
Field Summary |
static int |
CLUBS
The int value for the suit CLUBS, useful in accessing
suitPrefixes or for other purposes. |
static int |
DIAMONDS
The int value for the suit DIAMONDS, useful in accessing
suitPrefixes or for other purposes. |
static int |
HEARTS
The int value for the suit HEARTS, useful in accessing
suitPrefixes or for other purposes. |
static java.lang.String[] |
rankPrefixes
String values useful in constructing return values for
getCardId . |
static int |
SPADES
The int value for the suit SPADES, useful in accessing
suitPrefixes or for other purposes. |
static java.lang.String[] |
suitPrefixes
String values useful in constructing return values for
getCardId . |
Method Summary |
java.lang.String |
getCardId()
Return a value used in the gui Solitaire package, the returned
value must obey a contract: it's a two character lowercase string with
first character the rank, the second the suit. |
boolean |
isFaceUp()
Return true when the card is face up, and false otherwise. |
SPADES
static final int SPADES
- The int value for the suit SPADES, useful in accessing
suitPrefixes
or for other purposes.
- See Also:
- Constant Field Values
HEARTS
static final int HEARTS
- The int value for the suit HEARTS, useful in accessing
suitPrefixes
or for other purposes.
- See Also:
- Constant Field Values
CLUBS
static final int CLUBS
- The int value for the suit CLUBS, useful in accessing
suitPrefixes
or for other purposes.
- See Also:
- Constant Field Values
DIAMONDS
static final int DIAMONDS
- The int value for the suit DIAMONDS, useful in accessing
suitPrefixes
or for other purposes.
- See Also:
- Constant Field Values
rankPrefixes
static final java.lang.String[] rankPrefixes
- String values useful in constructing return values for
getCardId
.
suitPrefixes
static final java.lang.String[] suitPrefixes
- String values useful in constructing return values for
getCardId
.
getCardId
java.lang.String getCardId()
- Return a value used in the gui Solitaire package, the returned
value must obey a contract: it's a two character lowercase string with
first character the rank, the second the suit. The rank characters are
from "a23456789tjqk" and the suit characters are from "shcd".
- Returns:
- a card's id according to the contract specified in this class
isFaceUp
boolean isFaceUp()
- Return true when the card is face up, and false otherwise.
- Returns:
- true if and only if the card is face up