Question: JAVA Program TicTacToe Tic Tac Toe can be modeled by using a 2 dimensional array of characters (char[][]). There are 8 possible ways to win.

JAVA Program TicTacToe

Tic Tac Toe can be modeled by using a 2 dimensional array of characters (char[][]). There are 8 possible ways to win.

The interface IWinnableBoard below , can be implemented by any class that checks a 2 dimensional array of characters in order to determine if the board is a winner:

public interface IWinnableBoard {

boolean isWinner(char[][] board); }

Create class TicTacToeGame that implements interface IWinnableBoard. (must include interface). the shell is given below:

public class TicTacToeGame implements IWinnableBoard {

public class boolean isWinner(char[][] board) {

//implement isWinner method from IWinnableBoard here

//this method should have the logic to return true if the

//board contains 3 symbols of the same type in a row, false if

//otherwise

}

}

Now..... create a class TicTacToeGame. This class should have a main method in which you test your TicTacToeGame class. Below are the partial code examples.

Now create your own

char[][] case1Board = { X X X OOX OXO

System.out.println("Expect : true. Got: " +

char[][] case2Board = { X O X O O X O X O

System.out.println("Expect : false. Got: "+

winnerChecker.isWinner(case2Board));

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!