Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Making a Tic-Tac-Toe Game using Java. Winner can win horizontally, diagonally, and vertically. Not only that I have to have flexibility in expanding the tic-tac-toe

Making a Tic-Tac-Toe Game using Java.

Winner can win horizontally, diagonally, and vertically. Not only that I have to have flexibility in expanding the tic-tac-toe game to be able to fit any size and not just 3x3. For example, it can be 4x4 and it'll somewhat become like connecting four instead or even 2x2. However the default size is 3x3 if no input is placed.

If the size of the board is less than 1, throw an IllegalArgumentException.

If the "X" and "O" are not within the board such as in a 3x3 board if the user declares X to be at location (4,1), throw an IndexOutOfBoundException.

So I am suppose to use the following public methods:

public TTTBoard(int size)

public TTTBoard()

public char get(int r, int c) //return the character at the position (r,c)

public void set(int r, int c, char ch) //Change an already set character to another one.

public int size() //Makes the size, must be flexible not just 3x3

public char winner() //Finds the winner

public String toString() //Draws the board

| | -+-+- O| | -+-+- |X| //Example of how the board string should look like

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions