playTo
public boolean playTo(Card card)
throws java.lang.NullPointerException,
IllegalPlayException
Given a card to be played to the top of this card stack, either make the legal play and return true, or throw an appropriate Exception.
For a Cascade, the play is legal if either (1) the stack is empty, or (2) the top card is the next higher rank with differing color.
- Overrides:
playTo
in class CardStack
- Parameters:
card
- card to be played onto this card stack
- Returns:
- true if the card was played onto this card stack
- Throws:
java.lang.NullPointerException
- thrown if given Card parameter is null
IllegalPlayException
- thrown if "Plays to a cascade must alternate in suit color." or "Plays to a cascade must have the next decreasing rank." in that order.