|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object
|
+--GameModel
|
+--TicTacToeModel
This is the model for the TicTacToe game. It handles all the data involved in playing the game of tic tac toe which consists of trying to create a row, column or diagonal of x's or o's
| Fields inherited from class GameModel |
myGameName, myGamePieces, myGameStatus, myLastMoveStatus, myPlayingBoard |
| Fields inherited from interface GameStatusConstants |
GAME_IN_PROGRESS, GAME_LOST, GAME_OVER, GAME_TIED, GAME_WON |
| Fields inherited from interface LastMoveStatusConstants |
MOVE_SUCCESSFUL, MOVE_UNSUCCESSFUL |
| Method Summary | |
java.lang.Object |
clone()
allows a new model to be created fo the gui |
boolean |
colWin()
Return true if a column of 3 of the same pieces has been created |
boolean |
diagonalWin()
Return true if a diagonal of three of the same elements has been created |
javax.swing.JComponent |
getStatusDisplay()
|
boolean |
isGameOver()
return true if game is over/tied. |
boolean |
isGameWon()
return true if a row, column, or diagonal of 3 of the same elements has been created |
boolean |
isValid(int col,
int row)
returns true if there is no gamepiece at the specified row and column |
void |
move(int col,
int row,
GamePiece p)
sets the current player's gamepiece to the specified row and column of the board if there is no other piece at that location |
void |
newGame()
Creates a new playingboard, initializes status variables and sets game pieces on board |
void |
processClick(int col,
int row)
on click move currentgame piece at clicked col and row |
boolean |
rowWin()
check if a row of 3 of the same pieces has been created |
void |
setGamePieces()
set the gamepieces to be used in the game |
void |
updateGameStatus()
update the status of the game, set status variables that determine if game is won tied or still in progress |
| Methods inherited from class GameModel |
getBoardHeight, getBoardWidth, getGameName, getGamePieceAt, getGameStatus, getLastMoveStatus, getPlayingBoard, hasGamePieceAt, isGameLost, isGameTied, processClick, setGamePieceAt, wasLastMoveSuccessful |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public void newGame()
newGame in class GameModel
public boolean isValid(int col,
int row)
public void move(int col,
int row,
GamePiece p)
public void updateGameStatus()
updateGameStatus in class GameModelpublic boolean isGameWon()
isGameWon in class GameModelGameModelpublic boolean isGameOver()
isGameOver in class GameModelGameModelpublic boolean rowWin()
public boolean colWin()
public boolean diagonalWin()
public void processClick(int col,
int row)
processClick in class GameModelGameModelcol - is the number of the column that the click occurredrow - is the number of the row that the click occurredpublic void setGamePieces()
public javax.swing.JComponent getStatusDisplay()
getStatusDisplay in interface StatusInfopublic java.lang.Object clone()
clone in class GameModelGameModelGameModel
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||