java.lang.ObjectCard
public class Card
class Card here represents a playing card
Field Summary | |
---|---|
static int |
CLUBS
|
static int |
DIAMONDS
|
static int |
HEARTS
|
static java.lang.String[] |
pipName
pipName is an array that contains the name of the card's pips so that the index matches the number of the card. |
static int |
SPADES
|
static java.lang.String[] |
suitName
suitName is an array contains the name of the Suit so that the index matches the suit number |
static java.lang.String[] |
suitSymbol
suitSymbol Have the unicode values to print the correct symbol, arranges so thet the index matches the suit number |
Constructor Summary | |
---|---|
Card()
Default Constructor for objects of class Card is a random card of a random suit |
|
Card(int p,
int s)
A Card can be constructed with a determined number of pips (and integer 1-13) and suit (an integer from 0-3) |
|
Card(java.lang.String p,
java.lang.String s)
A Card can be constructed with a determined number of pips (a String "Ace" to "King") and suit (a String "Clubs" to "Spades") |
Method Summary | |
---|---|
int |
comparePips(Card c)
comparePips will return the difference between two cards' number of pips. |
int |
comparePipsAceHigh(Card c)
comparePipsAceHigh will return the difference between two cards' number of pips, Ace High. |
boolean |
equals(Card c)
Two cards are equal if they have the same number of pips. |
int |
getPips()
|
int |
getSuit()
|
int |
getValue()
|
int |
indexOf(java.lang.String[] a,
java.lang.String s)
indexOf returns the index of the String s in the String Array a (it returns -1 if not found). |
java.lang.String |
info()
info will return the contents of the card in a short two character string |
boolean |
isLessThan(Card c)
isLessThan will compare two cards by pips, and in case of a match, will compare the suit. |
void |
setPips(int p)
setPips changes the Card's pips, |
void |
setSuit(int s)
setSuit changes the Card's suit, |
java.lang.String |
toString()
toString will return the contents of the card in a string format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int CLUBS
public static final int DIAMONDS
public static final int HEARTS
public static final java.lang.String[] pipName
public static final int SPADES
public static final java.lang.String[] suitName
public static final java.lang.String[] suitSymbol
Constructor Detail |
---|
public Card()
public Card(int p, int s)
public Card(java.lang.String p, java.lang.String s)
Method Detail |
---|
public int comparePips(Card c)
public int comparePipsAceHigh(Card c)
public boolean equals(Card c)
public int getPips()
public int getSuit()
public int getValue()
public int indexOf(java.lang.String[] a, java.lang.String s)
public java.lang.String info()
public boolean isLessThan(Card c)
public void setPips(int p)
the
- pips are an integer from 1 to 13,
where 1 is an Ace and 13 is a King.public void setSuit(int s)
the
- suit 0 to 3. You can use the
predefined integer constants
SPADES, HEARTS, DIAMONDS and CLUBS
from the Card class.public java.lang.String toString()
toString
in class java.lang.Object