|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcs4099.State
public class State
This class represents a collection of Piles - it holds a specific state in a Solitaire game.
Pile
Constructor Summary | |
---|---|
State(State parent)
Creates a new State |
Method Summary | |
---|---|
void |
addPile(Pile pile)
Add a pile to this state (used in the interpretation stage). |
java.lang.String |
canPerformMove(Pile firstpile,
Pile secondpile)
Tests whether a move can be performed from this state, by considering two factors: 1. |
State |
copy()
Create an exact copy of this state, with duplicates of all piles and cards. |
int |
countCards()
Counts the number of cards in the entire state. |
int |
countCardsInFoundations()
Counts the number of cards in foundations. |
boolean |
equals(State newstate)
Method to test the state against another to check for duplicates. |
Card[] |
findrequiredcards()
Finds the cards required by the foundations in this state. |
Move[] |
findValidMoves()
Finds and returns all the valid moves from this state. |
State |
getSortedState()
Returns a new state with piles in order of properties, based on this state. |
int |
hashCode()
Returns a hash code for this state. |
void |
outputState()
Output this state to the command line in the form "[ID]: [Cards]". |
void |
performMove(int firstpileno,
int secondpileno)
Performs a move on the two piles corresponding to the passed values. |
void |
updateFoundations()
Updates the foundations of this state - gets all piles with the "isFoundation" attribute set to true, and adds their ID values into the foundations array for quick access. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public State(State parent)
parent
- The state from which the new state was createdMethod Detail |
---|
public void addPile(Pile pile)
pile
- The pile to add.public void outputState()
public State copy()
public java.lang.String canPerformMove(Pile firstpile, Pile secondpile)
firstpile
- The source pile for the movesecondpile
- The target pile for the move
public void performMove(int firstpileno, int secondpileno)
firstpileno
- The number of the source pile.secondpileno
- The number of the target pile.public boolean equals(State newstate)
newstate
- The state to compare with.
public Card[] findrequiredcards()
public State getSortedState()
public int hashCode()
hashCode
in class java.lang.Object
public void updateFoundations()
public int countCardsInFoundations()
public int countCards()
public Move[] findValidMoves()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |