|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object proj2.Game
public class Game
This class provides all methods used by the GUI for Monte Carlo Solitaire
Class Invariant:
To be supplied by the student
Constructor Summary | |
---|---|
Game(int rows,
int cols)
Construct a new Monte Carlo Solitaire object |
Method Summary | |
---|---|
int |
cardsLeft()
Calculates the number of cards still in the deck |
void |
consolidate()
Moves cards in the tableau towards the top (left and up) to replace the cards that were removed. |
proj2.Rank |
getRank(proj2.Coordinates coord)
Returns a Rank object representing the rank of the card at the specified Coordinates in the tableau |
proj2.Suit |
getSuit(proj2.Coordinates coord)
Returns a Suit object representing the suit of the card at the specified Coordinates in the tableau |
java.lang.String |
help()
Creates a String containing Help for the player |
proj2.Coordinates[] |
hint()
Finds two matching cards according to the rules of the game |
void |
newGame(long gameNr)
Starts a new game of solitaire. |
boolean |
playerWins()
Determines if the player has won the game by removing all the cards and thereby achieving a score of 52 |
boolean |
removeCards(proj2.Coordinates card1,
proj2.Coordinates card2)
Determines if the cards at the specified tableau locations are a match according to the rules of Monte Carlo Solitaire and if so, removes them from the tableau (formerly cardsMatch() ) |
void |
replay()
Restarts the current game |
int |
score()
Accessor for the player's current score |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Game(int rows, int cols)
rows
- the number of rows in the tableaucols
- the number of columns in the tableauMethod Detail |
---|
public int score()
public boolean playerWins()
public void newGame(long gameNr)
gameNr
- is the seed for the Random number generator used to shuffle the cards.public boolean removeCards(proj2.Coordinates card1, proj2.Coordinates card2)
cardsMatch()
)
card1
- - the coordinates of one card in the tableaucard2
- - the coordinates of the 2nd card in the tableau
Coordinates
public proj2.Suit getSuit(proj2.Coordinates coord)
coord
- - the coordinates of the card in the tableau
Coordinates
public proj2.Rank getRank(proj2.Coordinates coord)
coord
- - the Coordinates of the card in the tableau
Coordinates
public java.lang.String help()
public void replay()
public proj2.Coordinates[] hint()
null if no matching pair of cards exist
Coordinates
public void consolidate()
public int cardsLeft()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |