|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectFreecell
public class Freecell
The Freecell class allows the user to start a new game of Freecell, and move cards among the tableau piles, cells and foundation piles.
| Constructor Summary | |
|---|---|
Freecell()
Default constructor, intialize other objects |
|
| Method Summary | |
|---|---|
boolean |
checkCellNum(int c)
Checks if cell index is valid |
void |
checkFoundCards()
Checks if there are cards in the tableaus and/or cells that can be moved up to the foundation. |
boolean |
checkFoundNum(int f)
Checks if foundation index is valid |
boolean |
checkTabNum(int t)
Checks if tableau index is valid |
IGuiPileModel[] |
getCellArray()
Returns an array of the cells |
CellPiles |
getCells()
Returns the cell piles |
IGuiPileModel[] |
getFoundationArray()
Returns an array of the foundations |
FoundationPiles |
getFoundations()
Returns the foundation piles |
IGuiPileModel[] |
getTableauArray()
Returns an array of the tableaus |
TableauPiles |
getTableaus()
Returns the cell piles |
boolean |
isEnd()
Checks if the player has won the game, ie all the cards have been moved up to the foundations. |
boolean |
isIdEmpty(java.lang.String pileID)
Checks to see if the pile corresponding to the pileID is empty. |
static void |
main(java.lang.String[] args)
Runs the actually game, gets a freecell object passes in a view and creates the game. |
boolean |
move(char fromLoc,
int fromPos,
char toLoc,
int toPos)
Calls one of five move functions in freecell, based on the inputted from and to locations of the cards |
boolean |
moveCellToFound(int fromCell)
Moves card in Cell fromCell to foundation pile with same suit. |
boolean |
moveCellToTab(int fromCell,
int toTab)
Moves card in cell fromCell to Tableau toTab. |
boolean |
moveTabToCell(int fromTab,
int toCell)
Moves last card from Tableau fromTab to Cell toCell. |
boolean |
moveTabToFound(int fromTab)
Moves last card from Tableau fromTab to foundation pile with same suit. |
boolean |
moveTabToTab(int fromTab,
int toTab)
Moves numCards card(s) from Tableau fromTab to Tableau toTab. |
void |
newGame()
Starts a new game of Freecell, by erasing all the information from the previous game, and dealing out a new deck of cards. |
boolean |
playAgain()
Asks user if he/she wants to play a new game of freecell |
void |
startGame()
Starts the game, uses the view to intialize and allow user to play until the game has ended, if the game does end and user wants to start a new game then the user will be asked and according to his/her answer a new game will appear |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Freecell()
| Method Detail |
|---|
public void newGame()
public boolean moveTabToTab(int fromTab,
int toTab)
Conditions: fromTab contains at least numCards cards; top card in stack to be moved and last in toTab have alternate suit.
numCards - is the number of cards to be movedfromTab - is the index of the Tableau from which
the cards will be movedtoTab - is the index of the Tableau to which
the cards will be moved
public boolean moveTabToCell(int fromTab,
int toCell)
Conditions: fromTab contains at least one card, and toCell does not already contain a card.
fromTab - is the index of the Tableau from which
the card will be movedtoCell - is the index of the Cell to which
the card will be moved
public boolean moveTabToFound(int fromTab)
Conditions: fromTab contains at least one card, and the card to be moved is one rank higher than the rank of the top card in the corresponding foundation pile.
fromTab - is the index of the Tableau from
which the card will be moved
public boolean moveCellToTab(int fromCell,
int toTab)
Conditions: fromCell is not empty; card in fromCell and last card in toTab have alternate suit, and the rank of the former is one lower than that of the latter.
fromCell - is the index of the cell from which
the card will be movedtoTab - is the index of the Tableau to which
the card will be moved
public boolean moveCellToFound(int fromCell)
Conditions: fromCell is not empty, and the card to be moved is one rank higher than the rank of the top card in the corresponding foundation pile.
fromCell - is the index of the cell from
which the card will be moved
public void checkFoundCards()
public boolean isEnd()
public IGuiPileModel[] getFoundationArray()
public FoundationPiles getFoundations()
public IGuiPileModel[] getCellArray()
public CellPiles getCells()
public IGuiPileModel[] getTableauArray()
public TableauPiles getTableaus()
public boolean checkTabNum(int t)
public boolean checkFoundNum(int f)
public boolean checkCellNum(int c)
public void startGame()
public boolean playAgain()
public boolean isIdEmpty(java.lang.String pileID)
pileID -
public boolean move(char fromLoc,
int fromPos,
char toLoc,
int toPos)
fromLoc - specifies origin of card(s)
(tableau or cell)toLoc - specifies destination of card(s)
(tableau, cell or foundation)fromPos - = index of original tableau/celltoPos - = index of new tableau/cell
(Note: if moving to foundation, toPos is disregarded,
since there is only one possible foundation any card
can be moved to)numCards - specifies how many cards user wants
to move (only matters for movement between tableaus)
public static void main(java.lang.String[] args)
args -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||