Question: i need help finishing this gomoku assignment. import cs 2 5 1 . lab 2 . * ; public class Gomoku implements GomokuInterface { public
i need help finishing this gomoku assignment. import cslab;
public class Gomoku implements GomokuInterface
public int turn ;
private Square board;
private Square currentTurn;
private static final int NUMOFCOLUMNS ;
private static final int NUMOFROWS ;
private static final int POINTSTOWIN ;
public static void mainString args
Gomoku game new Gomoku;
if argslength
game.initComputerPlayerargs;
GomokuGUI.showGUIgame;
@Override
public int getNumCols
return NUMOFCOLUMNS;
@Override
public int getNumRows
return NUMOFROWS;
@Override
public int getNumInLineForWin
return POINTSTOWIN;
@Override
public TurnResult handleClickAtint row, int colthis is what changes the board
TurnResult gamenotover TurnResult.GAMENOTOVER;
TurnResult draw TurnResult.DRAW;
TurnResult crosswins TurnResult.CROSSWINS;
TurnResult ringwins TurnResult.RINGWINS;
boardrowcol currentTurn;
String currentBoard getCurrentBoardAsString;
System.out.printlnThis is the current board: currentBoard ;
if row row NUMOFROWS col col NUMOFCOLUMNS
throw new MyCustomExceptionIllegal move!";
if boardrowcol Square.EMPTY
System.out.printlnSquare at row col is already occupied.";
return gamenotover;
if hasWinningMove board, row, col, currentTurn
System.out.printlnPlayer currentTurn wins!";
return currentTurn Square.CROSS crosswins : ringwins;
if boardFull
System.out.printlnIts a tie! The board is full.";
return draw;
turn;
switchTurn;
return gamenotover;
@Override
public void initializeGame
this.board new SquareNUMOFROWSNUMOFCOLUMNS;
this.currentTurn Square.EMPTY;
@Override
public String getCurrentBoardAsString
StringBuilder squareThing new StringBuilder;
for int r ; r NUMOFCOLUMNS; r
for int c ; c NUMOFROWS; c
boardrc Square.EMPTY;
return squareThing.toString;
@Override
public Square getCurrentTurn
return currentTurn;
@Override
public void initComputerPlayerString s
public class MyCustomException extends RuntimeException
public MyCustomExceptionString message
supermessage;
private void switchTurn
private boolean boardFull
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
