|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectscrabble.Scrabble
public class Scrabble
Maintains the state of the game, checks for legal plays, calculates scores, finds best plays.
Field Summary | |
---|---|
static char[][] |
DEFAULT_BOARD_LAYOUT
Default board configuration |
static int |
DEFAULT_BOARD_SIZE
Default board size |
static int[] |
DEFAULT_LETTER_COUNTS
Array storing the standard number of tiles for each letter A-Z (blank is at the end) |
static int |
DEFAULT_MAX_HAND_SIZE
Default maximum number of tiles in hand |
static int[] |
DEFAULT_POINT_VALUES
Array storing the standard letter point values A-Z (blank is at the end). |
Constructor Summary | |
---|---|
Scrabble()
Perform initializations common to all Scrabble games. |
|
Scrabble(ScrabbleDictionary dictionary)
Creates a new standard scrabble game with random tile bag |
|
Scrabble(ScrabbleDictionary dictionary,
java.util.ArrayList<java.lang.Character> tileBag)
Create a new scrabble game in which no plays have been made. |
|
Scrabble(ScrabbleDictionary dictionary,
java.lang.String fileName)
Creates a Scrabble object using the data in the given .scrabble file (the state of the game at any given moment). |
Method Summary | |
---|---|
static ScrabbleDictionary |
createDictionary(java.lang.String fileName)
Returns a new ScrabbleDictionary created by reading the file specified in the fileName parameter. |
void |
drawTile()
Move last tile in tileBag to the player's hand |
char[][] |
getBoardChars()
|
char[][] |
getBoardConfiguration()
|
int |
getBoardSize()
|
GameState |
getCurrentGameState()
Accessor method for Scrabble's currentGameState field. |
ScrabbleDictionary |
getDictionary()
|
java.lang.String |
getLastWordPlayed()
|
int |
getMaxHandSize()
|
int |
getScoreThisTurn()
|
java.util.ArrayList<java.lang.Character> |
getTileBag()
|
java.util.ArrayList<java.lang.Character> |
getTilesInHand()
|
int |
getTotalScore()
|
java.util.ArrayList<GameState> |
playGame()
Will play the entire game and return an ArrayList of GameStates that represent each step of play from the end of the next play until the end of the game. |
GameState |
playOnce()
Will play one turn in the Scrabble game and return a new GameState that contains the values that have changed during play. |
GameState |
playOnceHuman(java.lang.String toPlay,
int rowStart,
int colStart,
boolean vertical)
Plays toPlay (in the order given), starting at zero-based position (rowStart, colStart). |
void |
returnTiles(char[] tilesToReturn)
Takes in a certain number of tiles, x, that should be removed from the users hand and placed back in the tileBag. |
void |
shuffle()
Should shuffle this game's tileBag into a new random order. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BOARD_SIZE
public static final int DEFAULT_MAX_HAND_SIZE
public static final char[][] DEFAULT_BOARD_LAYOUT
public static final int[] DEFAULT_POINT_VALUES
public static final int[] DEFAULT_LETTER_COUNTS
Constructor Detail |
---|
public Scrabble()
public Scrabble(ScrabbleDictionary dictionary) throws java.lang.Exception
dictionary
-
java.lang.Exception
public Scrabble(ScrabbleDictionary dictionary, java.util.ArrayList<java.lang.Character> tileBag)
dictionary
- - dictionary to be used in this instance of ScrabbletileBag
- - tiles to be drawn frompublic Scrabble(ScrabbleDictionary dictionary, java.lang.String fileName) throws java.io.IOException
dictionary
- A Scrabble dictionaryfileName
- name (must end in '.scrabble')
java.io.IOException
- if the given file name is not found or does not end in scrabbleMethod Detail |
---|
public void drawTile()
public GameState getCurrentGameState()
public GameState playOnce()
public java.util.ArrayList<GameState> playGame()
public GameState playOnceHuman(java.lang.String toPlay, int rowStart, int colStart, boolean vertical) throws java.lang.IllegalArgumentException, java.lang.IndexOutOfBoundsException
toPlay
- rowStart
- colStart
- vertical
-
java.lang.IllegalArgumentException
- if the play tries to make an illegal word.
java.lang.IndexOutOfBoundsException
- if the placement is illegal (some tiles would be outside the board,
first play does not include the center square, subsequent play does not touch any previously-played letters.public void returnTiles(char[] tilesToReturn)
tilesToReturn
- - tiles to be put back in the tileBagpublic void shuffle()
public static ScrabbleDictionary createDictionary(java.lang.String fileName)
fileName
- - the name of the file in which the dictionary is located.
public char[][] getBoardChars()
public char[][] getBoardConfiguration()
public int getBoardSize()
public int getMaxHandSize()
public int getScoreThisTurn()
public java.util.ArrayList<java.lang.Character> getTileBag()
public java.util.ArrayList<java.lang.Character> getTilesInHand()
public int getTotalScore()
public ScrabbleDictionary getDictionary()
public java.lang.String getLastWordPlayed()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |