|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object smithers.cards.Klondike
public class Klondike
Represents a game of Klondike, also known as Canfield in the UK. For the rules, see http://en.wikipedia.org/wiki/Klondike_(solitaire). Notice that the methods in this class are precisely those available to the player.
Constructor Summary | |
---|---|
Klondike()
Creates a new game of Klondike. |
Method Summary | |
---|---|
int |
deckLength()
Returns the number of cards remaining in the deck. |
void |
draw()
Draws from the deck to the wastepile. |
int |
drawsLeft()
Returns the remaining number of times the wastepile can be turned over to the deck. |
int |
faceDownLength(int col)
Returns the number of face down cards in the specified tableau column. |
Card |
foundationTopCard(int col)
Returns the top card in the specified foundation pile. |
void |
move(int from,
int to)
Attempts to move cards from one location to another. |
Card[] |
tableauCards(int col)
Returns an array of the cards in the specified tableau column. |
Card[] |
visibleWaste()
Returns an array of the visible cards in the wastepile. |
boolean |
won()
Checks if the game has been won. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Klondike()
Method Detail |
---|
public boolean won()
true
if the game has been wonpublic Card foundationTopCard(int col)
null
.
col
- the index of the foundation pile
public int faceDownLength(int col)
col
- the index of the tableau column
public Card[] tableauCards(int col)
col
- the index of the tableau column
public int deckLength()
public Card[] visibleWaste()
public int drawsLeft()
public void draw()
public void move(int from, int to)
from == 0
or the indicated column of the
tableau if 1 <= from && from <= 7
. Cards are moved to the
foundations if to == 0
or the indicated column of the tableau if
1 <= from && from <= 7
. One card will be moved, unless both
indices refer to the tableau, in which case whatever number of cards can
be moved will be. If no cards can be moved, a CardMoveException
will be thrown.
from
- the location to move fromto
- the location to move to
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |