|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcs4099.Pile
public class Pile
A class that represents a pile in a Solitaire game. Piles hold cards, and have specific rules as to the cards that can be placed on them at any time.
Card
,
State
Constructor Summary | |
---|---|
Pile(int id,
int capacity,
int order,
int uniquesuit,
boolean alternatecolours,
boolean samesuit,
boolean removable,
boolean addable,
boolean isfoundation,
int stocknumber,
int cardstodeal,
boolean isstock,
int stockcapacity,
int startvalue,
boolean oneaway,
boolean oneawaynowrap,
boolean fourteens,
int displayx,
int displayy,
boolean straightstack,
boolean backwards)
Creates a new instance of Pile. |
Method Summary | |
---|---|
boolean |
addCard(Card card)
Adds a card on to a pile, if it does not go against the constraints of the pile. |
void |
buryKings()
Buries the Kings on this pile (sends all cards with value 13 to the beginning). |
java.lang.String |
canAddCard(Card card)
Determines whether a card can be added to the pile. |
boolean |
canRemoveCard()
Verifies whether the top card can be removed, without actually removing it. |
int |
compareTo(Pile pile)
Returns "true" if this pile is found to be "greater than" another, based on its attributes and contents but not its ID number. |
int |
contains(Card[] cards)
Returns information on whether any of a set of cards exist in this pile. |
boolean |
dealCard(Card card)
Forces adding a card to a pile - used in dealing the cards rather than playing them. |
boolean |
equalsByContents(Pile otherpile)
A method to compare the contents of this pile with another, and to return "true" if the contents are equal. |
Card |
getTopCard()
Returns the top card of this pile - a shortcut for getting its suit and value. |
boolean |
isequivalent(Pile pile)
Examines whether a pile's properties are equivalent to another, including the suits and values of the cards in them. |
Card |
removeCard()
Returns the topmost card, or a null if the topmost card cannot be removed. |
java.lang.String |
toString()
Returns a String representation of this pile for output. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Pile(int id, int capacity, int order, int uniquesuit, boolean alternatecolours, boolean samesuit, boolean removable, boolean addable, boolean isfoundation, int stocknumber, int cardstodeal, boolean isstock, int stockcapacity, int startvalue, boolean oneaway, boolean oneawaynowrap, boolean fourteens, int displayx, int displayy, boolean straightstack, boolean backwards)
id
- The ID number of the pile.capacity
- The pile's capacity (length of the array used to hold cards)order
- The numerical order in which cards must be placed - 1 specifies building up, -1 to build down.uniquesuit
- Should be set to 0-3 if the pile should only accept one suit, -1 otherwise.alternatecolours
- Set to true if cards must be placed on the pile in alternating colours.samesuit
- Set to true if cards added to the pile must be of the same suit as the card below.removable
- Set to true if cards can be removed from this pile (unless the pile is a stock).addable
- Set to true if cards can be added from this pile.isfoundation
- Set to true if this pile is to be regarded as a goal pile.stocknumber
- The number of the stock that this pile is filled from (-1 if none).cardstodeal
- The number of random cards to deal to this pile at the start of the game.isstock
- Set to true if this pile should behave as a stock pile.stockcapacity
- The number of cards to deal from this pile (if a stock) at one time.startvalue
- The value that a card must be to fill this pile if it is empty (0 if any).oneaway
- Set to true if cards with adjacent values must be added to this pile (wrapping between A-K allowed).oneawaynowrap
- Set to true if cards with adjacent values must be added to this pile (wrapping between A-K disallowed).fourteens
- Set to true if this pile must accept cards in pairs that total fourteen numerically.displayx
- The X position for this pile on the desktop.displayy
- The Y position for this pile on the desktop.straightstack
- Set to true if only the top card is to be displayed.backwards
- Set to true if this pile should be drawn upwards instead of downwards.Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public boolean addCard(Card card)
public boolean dealCard(Card card)
public java.lang.String canAddCard(Card card)
card
- The card to attempt to add to the pile.
public Card removeCard()
public boolean canRemoveCard()
public Card getTopCard()
public boolean isequivalent(Pile pile)
pile
- The pile to compare against.
public int contains(Card[] cards)
cards
- The array of cards to find.
public int compareTo(Pile pile)
pile
- The pile to compare to
public boolean equalsByContents(Pile otherpile)
otherpile
- The pile to compare to.
public void buryKings()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |