Class PlayingCard

java.lang.Object
  extended by PlayingCard
All Implemented Interfaces:
java.lang.Comparable<PlayingCard>

public class PlayingCard
extends java.lang.Object
implements java.lang.Comparable<PlayingCard>


Constructor Summary
PlayingCard(int cardRank, char cardSuit)
          Constructs a single playing card given the card rank and suit in the parameters.
 
Method Summary
 int compareTo(PlayingCard otherCard)
          Returns a positive integer if this card has a lower rank than the other card, a negative integer if this card has a higher rank than the other card, or 0 if this card's rank is the same as the other card's rank.
 java.lang.String getImageFileName()
          Gets the image file name for this card.
 int getRank()
          Gets the rank of this card.
 char getSuit()
          Gets the suit of this card.
 java.lang.String toString()
          Returns the string representation of this card including its rank and suit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PlayingCard

public PlayingCard(int cardRank,
                   char cardSuit)
Constructs a single playing card given the card rank and suit in the parameters. If either rank or suit is invalid, a warning is output and an Ace of Spades is created.

Parameters:
cardRank - The rank of the desired card from 1 (Ace). 2, 3, ..., 10, 11 (Jack), 12 (Queen), 13 (King)
cardSuit - The suit of the desired card ('C' is Clubs, 'S' is Spades, 'H' is Hearts, 'D' is Diamonds)
Method Detail

getRank

public int getRank()
Gets the rank of this card.

Returns:
The rank of this card as an integer between 1 and 13 (1 is Ace, 11 is Jack, 12 is Queen, 13 is King).

getSuit

public char getSuit()
Gets the suit of this card.

Returns:
The suit of this card as a char ('C' is Clubs, 'S' is Spades, 'H' is Hearts, 'D' is Diamonds).

getImageFileName

public java.lang.String getImageFileName()
Gets the image file name for this card. The image file name for a card consists of its rank followed by its suit followed by the suffix ".png". For example: the Ace of Spades would have a file name of "1S.png", the 7 of Diamonds would have a file name of "7D.png" and the Jack of Hearts would have a file name of "11H.png".

Returns:
The file name of this card.

toString

public java.lang.String toString()
Returns the string representation of this card including its rank and suit.

Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(PlayingCard otherCard)
Returns a positive integer if this card has a lower rank than the other card, a negative integer if this card has a higher rank than the other card, or 0 if this card's rank is the same as the other card's rank.

Specified by:
compareTo in interface java.lang.Comparable<PlayingCard>