p2Util
Class Card

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

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

The Card class models a single card identified by Rank and Suit

Class Invariant
Suit and Rank are not null
Card objects are immutable


Constructor Summary
Card(p2Util.Suit suit, p2Util.Rank rank)
          Precondition: Suit and Rank are not null
Postcondition: A new Card object is initialized
 
Method Summary
 int compareTo(Card card)
          This method compares the calling Card with the Card parameter base on Rank
 java.lang.String getFileName()
          Preconditions: none
Postconditions: returns the name of this Card's image file for GUI base applications
 java.lang.String getName()
          Preconditions: none
Postconditions: returns the name of this Card for text base applications
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Card

public Card(p2Util.Suit suit,
            p2Util.Rank rank)
Precondition: Suit and Rank are not null
Postcondition: A new Card object is initialized

Method Detail

getName

public java.lang.String getName()
Preconditions: none
Postconditions: returns the name of this Card for text base applications

Returns:
The long name of the Card as a String

getFileName

public java.lang.String getFileName()
Preconditions: none
Postconditions: returns the name of this Card's image file for GUI base applications

Returns:
The Card image file name as a String

compareTo

public int compareTo(Card card)
This method compares the calling Card with the Card parameter base on Rank

Precondition: parameter card is not null
Postcondition:
returns negative if the calling Card's Rank is less than the parameter's Rank
returns positive if the calling Card's Rank is greater than the parameter's Rank
returns 0 if the Card Ranks are the same

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