java.lang.Object
model.logic.host.data.Board
- All Implemented Interfaces:
Serializable
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanboardLegal(Word word) The boardLegal function checks if a word is legal to be placed on the board.booleandictionaryLegal(Word word) The dictionaryLegal function checks if the word is in the dictionary.static BoardgetBoard()The getBoard function is a static function that returns the single instance of the Board class.Tile[][]getTiles()The getTiles function returns a copy of the board.voidThe printBoard function prints the board to the console.inttryPlaceWord(Word newWord) The tryPlaceWord function takes a Word object as an argument and returns an integer.
-
Method Details
-
getBoard
The getBoard function is a static function that returns the single instance of the Board class. This is used to ensure that there are no multiple instances of the board, and thus no confusion about which board we are referring to when we call functions on it.- Returns:
- A singleton instance of the board class
-
getTiles
The getTiles function returns a copy of the board.- Returns:
- A copy of the board
-
boardLegal
The boardLegal function checks if a word is legal to be placed on the board. If the board is empty, then it must go on the star square and stay in bounds. If not, then it must be in bounds and have an adjacent or overlapping tile.- Parameters:
word- word Check if the word is in bounds- Returns:
- True if the board is empty and the word is on the star square
-
dictionaryLegal
The dictionaryLegal function checks if the word is in the dictionary.- Parameters:
word- word Pass in the word that is being checked- Returns:
- True if the word is in the dictionary and false otherwise
-
tryPlaceWord
The tryPlaceWord function takes a Word object as an argument and returns an integer. The function checks if the word can be placed on the board, and if it can, adds it to the board. If not, then - 1 is returned. If there are words created by placing this new word on the board that are not in our dictionary, 0 is returned. Otherwise, we return a score for how many points were earned by placing this new word on our game-board (the sum of all scores of all words created).- Parameters:
newWord- newWord Pass the word that is being placed on the board- Returns:
- - 1 if the word cannot be placed on the board
-
printBoard
public void printBoard()The printBoard function prints the board to the console.
-