public class CardStack
extends java.lang.Object
Constructor and Description |
---|
CardStack() |
Modifier and Type | Method and Description |
---|---|
void |
addCard(Card card)
Add the given card to the top of the stack.
|
boolean |
canPlayFrom()
Return whether or not a card may be removed from this stack.
|
Card |
getTopCard()
Return the top card (or null if empty).
|
boolean |
isEmpty()
Return whether or not the card stack is empty.
|
boolean |
playTo(Card card)
Given a card to be played to the top of this card stack, either make the legal play and return true, or ignore the illegal play and return false.
|
boolean |
playTo(CardStack otherStack)
Given a stack from which the top card is to be played to the top of this card stack, either make the legal play and return true, or ignore the illegal play and return false.
|
Card |
removeTopCard()
Remove the top card and return it (or null if empty).
|
int |
size()
Return the size of the card stack.
|
Card[] |
toArray()
Return an array of Card objects in this stack, ordered bottom to top.
|
java.lang.String |
toString() |
protected java.util.Stack<Card> stack
public void addCard(Card card)
card
- card to addpublic boolean canPlayFrom()
public Card getTopCard()
public boolean isEmpty()
public boolean playTo(Card card)
card
- card to be played onto this card stackpublic boolean playTo(CardStack otherStack)
otherStack
- the other stack from which the top card is to be playedpublic Card removeTopCard()
public int size()
public java.lang.String toString()
toString
in class java.lang.Object
public Card[] toArray()