Question: Please write code for Board.java (class) and TicTacToe.java (driver class)- in basic java - and include ALL parts of the prompt below (see bolded). I

Please write code for Board.java (class) and TicTacToe.java (driver class)- in basic java - and include ALL parts of the prompt below (see bolded). I need separate classes, the driver being TicTacToe.java and the class without a main method being Board.java --- NOT combined in one. Please also include my teacher's toString class. Thank you!!

My teacher's instructions: Your task is to create a game of Tic-Tac-Toe using a 2-Dimensional String array as the game board. Start by creating a Board class that holds the array. The constructor should use a traditional for-loop to fill the array with "blank" Strings (eg. "-"). You may want to include other instance data... Include the follwoing methods: public void setSpace(int row, int col, String s) will change a specific space to have either "X" or "O", but only if the space is available. public boolean hasThree(String s) will check to see if there are 3 in a row, column, or diagonal. public String toString() will generate a String that displays the Board with appropriate formatting. Create a driver class called TicTacToe that instantiates a Board object and allows 2 players to go head to head in a the game.

Teacher's toString class (completed):

public String toString() { String result = ""; result += " | | "; result += " " + board[0][0] + " | " + board[0][1] + " | " + board[0][2] + " "; result += "_____|_____|_____ "; result += " | | "; result += " " + board[1][0] + " | " + board[1][1] + " | " + board[1][2] + " "; result += "_____|_____|_____ "; result += " | | "; result += " " + board[2][0] + " | " + board[2][1] + " | " + board[2][2] + " "; result += " | | "; return result; } 

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!