java.lang.Object
ViewModel.ScrabbleViewModel
- All Implemented Interfaces:
Observer
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionThe ScrabbleViewModel function is the constructor for the ScrabbleViewModel class. -
Method Summary
Modifier and TypeMethodDescriptionvoidThe disconnect function disconnects the client from the server.javafx.beans.property.ObjectProperty<Character[][]>getBoard()The getBoard function returns the boardProperty object.javafx.beans.property.BooleanPropertyThe getDisconnect function returns the disconnect property.javafx.beans.property.BooleanPropertyjavafx.beans.property.BooleanPropertyThe getGameStartedProperty function returns the gameStarted property.Character[][]javafx.beans.property.ListProperty<String>The getScores function is a getter function that returns the scores list property.javafx.beans.property.ListProperty<Character>getTiles()The getTiles function returns the tiles property of the Board class.voidskipTurn()The skipTurn function is used to skip the current player's turn.voidThe startGame function is used to start the game.booleanThe submitWord function is used to submit a word that the player has created.voidupdate(Observable o, Object arg)
-
Field Details
-
myTurn
public final javafx.beans.property.BooleanProperty myTurn -
gameOver
public final javafx.beans.property.BooleanProperty gameOver
-
-
Constructor Details
-
ScrabbleViewModel
The ScrabbleViewModel function is the constructor for the ScrabbleViewModel class. It takes in a ScrabbleModelFacade object and sets it to be an instance variable of this class. It also adds itself as an observer to the model, initializes all of its properties, and creates a 2D array that will hold previous board states.- Parameters:
m- Set the model- Throws:
IOException
-
-
Method Details
-
getTiles
The getTiles function returns the tiles property of the Board class.- Returns:
- The tiles property
-
getBoard
The getBoard function returns the boardProperty object.- Returns:
- A property of type character[][]
-
getPrevBoard
-
startGame
public void startGame()The startGame function is used to start the game. It sets the boolean value of gameStarted to true, and then calls on model's startGame function. The tiles are set equal to what model returns from its startGame function. -
getDisconnect
public javafx.beans.property.BooleanProperty getDisconnect()The getDisconnect function returns the disconnect property.- Returns:
- A booleanproperty
-
disconnect
public void disconnect()The disconnect function disconnects the client from the server. -
submitWord
The submitWord function is used to submit a word that the player has created. It takes in no parameters and returns a boolean value of true if the word was submitted successfully, or false if it wasn't. The function first gets the answer from getWord(), which is then split into an array of strings, where each string represents one part of the answer (the word itself, its starting row position on boardProperty, its starting column position on boardProperty and whether it's horizontal or vertical). Then we call model.submitWord() with these values as parameters to check whether this move is valid according to our game rules (- Returns:
- A boolean value
- Throws:
IOException
-
skipTurn
The skipTurn function is used to skip the current player's turn.- Throws:
IOExceptionInterruptedException
-
getScores
The getScores function is a getter function that returns the scores list property.- Returns:
- An observable list of strings
-
getGameStartedProperty
public javafx.beans.property.BooleanProperty getGameStartedProperty()The getGameStartedProperty function returns the gameStarted property.- Returns:
- The gamestarted property
-
update
-
getGameOver
public javafx.beans.property.BooleanProperty getGameOver()
-