proj3
Class Game

java.lang.Object
  extended by proj3.Game

public class Game
extends java.lang.Object

This class provides all methods used by the GUI for Monte Carlo Solitaire. Class Invariant: to be supplied by the student.

Author:
You

Constructor Summary
Game(int tableauRows, int tableauColumns)
          Construct a new Monte Carlo Solitaire object
 
Method Summary
 void consolidate()
          Moves cards in the tableau towards the top (left and up) to replace the cards that were removed.
 java.lang.String getHelpText()
          Returns a help message explaining the rules of the game.
 Coordinate[] getHint()
          Finds two matching cards according to the rules of the game (NOTE: this method should only be called if isHintImplemented() returns true
 Rank getRank(Coordinate coordinates)
          Returns a Rank enum representing the rank of the card at the specified coordinate in the tableau
 int getScore()
          Returns the player's score for the current game
 Suit getSuit(Coordinate coordinate)
          Returns a Suit enum representing the suit of the card at the specified coordinate in the tableau
 boolean isHintImplemented()
          Indicates that the EXTRA CREDIT hint feature (getHint()) was implemented.
 boolean isWin()
          Determines if the player has won the game by removing all the cards and thereby achieving a score of 52
 void newGame(long gameNumber)
          Starts a new game of solitaire for the specified game number in accordance to project specifications.
 int numberOfCardsLeft()
          Returns the number of cards left in the deck
 boolean removeCards(Coordinate coordinate1, Coordinate coordinate2)
          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
 void replay()
          Restarts the current game
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Game

public Game(int tableauRows,
            int tableauColumns)
Construct a new Monte Carlo Solitaire object

Parameters:
tableauRows - the number of rows in the tableau
tableauColumns - the number of columns in the tableau
Method Detail

newGame

public void newGame(long gameNumber)
Starts a new game of solitaire for the specified game number in accordance to project specifications.

Parameters:
gameNumber - the game number to play

numberOfCardsLeft

public int numberOfCardsLeft()
Returns the number of cards left in the deck

Returns:
the number of cards

getScore

public int getScore()
Returns the player's score for the current game

Returns:
the score

getSuit

public Suit getSuit(Coordinate coordinate)
Returns a Suit enum representing the suit of the card at the specified coordinate in the tableau

Parameters:
coordinate - the coordinate of the card in question
Returns:
the Suit of the card

getRank

public Rank getRank(Coordinate coordinates)
Returns a Rank enum representing the rank of the card at the specified coordinate in the tableau

Parameters:
coordinates - the coordinate of the card in questions
Returns:
the Rank of the card

getHelpText

public java.lang.String getHelpText()
Returns a help message explaining the rules of the game.

Returns:
the rules of the game

replay

public void replay()
Restarts the current game


consolidate

public void consolidate()
Moves cards in the tableau towards the top (left and up) to replace the cards that were removed. Then deals cards from the deck to refill the empty spaces at the bottom of the tableau.


isHintImplemented

public boolean isHintImplemented()
Indicates that the EXTRA CREDIT hint feature (getHint()) was implemented.

Returns:
true if the hint feature is functional, false otherwise
See Also:
getHint()

getHint

public Coordinate[] getHint()
Finds two matching cards according to the rules of the game (NOTE: this method should only be called if isHintImplemented() returns true

Returns:
an array of 2 Coordinates for the matching cards if found, null if no match is found
See Also:
isHintImplemented()

removeCards

public boolean removeCards(Coordinate coordinate1,
                           Coordinate coordinate2)
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

Parameters:
coordinate1 - the coordinate of the first card
coordinate2 - the coordinate of the second card
Returns:
true if cards can be removed, false otherwise

isWin

public boolean isWin()
Determines if the player has won the game by removing all the cards and thereby achieving a score of 52

Returns:
true if the player has won, false otherwise