Class Card
java.lang.Object
|
+--Card
- public class Card
- extends Object
Class for representing a playing card.
January 1999
- Author:
- Craig Miller
Constructor Summary |
Card(char initRank,
char initSuit)
|
Card
public Card(char initRank,
char initSuit)
- Parameters:
initRank
- The initial rank should be one of the following characters:
'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'initSuit
- The initial suit should be one of the following characters:
'S', 'D', 'H', 'C'
- Postcondition:
-
The card's values are set to initRank and initSuit.
getRank
public char getRank()
- Returns:
- The rank of the card.
toString
public String toString()
- Overrides:
toString
in class Object
- Returns:
- printable string display of card
getSuit
public char getSuit()
- Returns:
- The suit of the card.
getRankValue
public int getRankValue()
- Returns:
- The rank value, ranging from 2 to 14, of the card. The
rank of the Ace ('A') is 14.
- Throws:
RuntimeException
- Indicates that card is holding an illegal rank.
main
public static void main(String[] args)