|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectDeck
public class Deck
This class models a deck of fifty-two ordinary playing cards OR a deck of fifty-four cards that includes two jokers.
| Constructor Summary | |
|---|---|
Deck()
Constructs a new deck of cards, ace through king of each suit, with the suits in "bridge-order." |
|
Deck(int n)
Constructs a new deck of n cards; the only Permissable values for n are 52 and 54. |
|
| Method Summary | |
|---|---|
Card |
cardAt(int i)
Returns (a copy of) the card at index i in this deck. |
boolean |
contains(Card c)
Returns true iff this deck contains at least one card that is just like Card c. |
static double |
dispersion(Deck d1,
Deck d2)
Returns the dispersion between two joker-less decks, defined as the average (absolute) distance that each card has to move in order to transform d1 into d2. |
boolean |
equals(Deck d)
Returns true iff this deck and d are identically constructed. |
boolean |
isCrooked()
Returns true iff this deck is crooked (contains multiple copies of some card or cards). |
static void |
main(java.lang.String[] args)
Skeleton suite of unit tests for the "missing" methods, above. |
void |
putCard(Card c,
int i)
|
void |
randomShuffle()
Performs a randomized shuffle of this deck. |
void |
riffleShuffle()
Performs a riffle shuffle of this deck, i.e., the kind of shuffle you do by hand. |
int |
size()
Returns the size of the deck (52 for normal decks, 54 for decks with jokers). |
java.lang.String |
toString()
Returns a representation of this deck. |
int |
whereIs(Card c)
Returns the index of (the first example of) card c in this deck (-1 if not found). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Deck()
public Deck(int n)
| Method Detail |
|---|
public static double dispersion(Deck d1,
Deck d2)
public Card cardAt(int i)
public java.lang.String toString()
toString in class java.lang.Objectpublic int size()
public void riffleShuffle()
public void randomShuffle()
public boolean contains(Card c)
public void putCard(Card c,
int i)
public int whereIs(Card c)
public boolean equals(Deck d)
public boolean isCrooked()
public static void main(java.lang.String[] args)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||