java.lang.Object
java.util.Observable
Model.Model
Model.PlayerModel
Model.GuestModel
- All Implemented Interfaces:
Observer
Guest model class
-
Constructor Summary
ConstructorsConstructorDescriptionGuestModel(String ip, int port, String name) build a model for the guest and connect to the host server using clientCommunication -
Method Summary
Modifier and TypeMethodDescriptionvoidwill ask from the server to challenge the wordvoidvoidCharacter[][]intvoidsetBoardStatus(Character[][] board) will update the board statusvoidCharacter[][]voidtakeTileFromBag function that will ask from the server to take a tile from the bagvoidtryPlaceWord(String word, int col, int row, boolean isVertical) will ask from the server to put a word on the boardvoidupdate(Observable o, Object arg) receive updates from the observable objectMethods inherited from class Model.PlayerModel
getCurrentPlayerId, getMyTiles, setCurrentPlayerIdMethods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
-
Constructor Details
-
GuestModel
build a model for the guest and connect to the host server using clientCommunication- Parameters:
ip- = ip of the host serverport- = port of the host servername- = name of the player
-
-
Method Details
-
startGame
public void startGame() -
connectToHostServer
public void connectToHostServer() -
closeConnection
public void closeConnection()- Specified by:
closeConnectionin classModel
-
tryPlaceWord
will ask from the server to put a word on the board- Specified by:
tryPlaceWordin classModel- Parameters:
word- - string of the word that the user is trying to put on the boardcol- - index of the starting column of the wordrow- - index of the starting row of the wordisVertical- - a boolean indicating if the word is vertical(true) or horizontal(false)
-
challenge
will ask from the server to challenge the word -
takeTileFromBag
public void takeTileFromBag()takeTileFromBag function that will ask from the server to take a tile from the bag- Specified by:
takeTileFromBagin classModel
-
getBoardStatus
- Specified by:
getBoardStatusin classModel- Returns:
- - the most updated state of the board
-
setBoardStatus
will update the board status- Parameters:
board- - represent the updated state of the board
-
getNumberOfTilesInBag
public int getNumberOfTilesInBag()- Specified by:
getNumberOfTilesInBagin classModel- Returns:
- - the current number of tiles in the bag
-
getPlayersScores
- Specified by:
getPlayersScoresin classModel- Returns:
- - a map from a player's id to the player's score
-
getClientCommunication
-
getPlayersNameMap
-
getPlayersNumberOfTiles
- Specified by:
getPlayersNumberOfTilesin classModel- Returns:
- - a map from a player's id to the player's score
-
stringToCharacterMatrix
- Parameters:
s- - a string that represents the current state of the board- Returns:
- - a matrix of characters that represent the "s" string
-
getMyHand
-
update
receive updates from the observable object
-