Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me with this lab? //(c) A+ Computer Science //www.apluscompsci.com //Name - import java.util.Scanner; import static java.lang.System.*; public class TicTacToe { private char[][]

Can someone help me with this lab?

image text in transcribed

//(c) A+ Computer Science

//www.apluscompsci.com

//Name -

import java.util.Scanner;

import static java.lang.System.*;

public class TicTacToe

{

private char[][] mat;

public TicTacToe()

{

}

public TicTacToe(String game)

{

mat = new char [3][3];

int cnt = 0;

for(int r=0;r

{

for(c=0; c

{

mat[r][c]=game.charAt(cnt);

cnt++;

}

}

}

public String getWinner()

{

return "";

}

public String toString()

{

String output="";

return output+" ";

}

}

////////////////////////////////////////////////////////////////////////////////////////////

//(c) A+ Computer Science

//www.apluscompsci.com

//Name -

import java.io.File;

import java.io.IOException;

import java.util.Scanner;

import static java.lang.System.*;

public class TicTacToeRunner

{

public static void main( String args[] ) throws IOException

{

}

}

Lab GoalThis lab was designed to teach you how to use a matrix, an array of arrays Lab Description Read in the values for a tic tac toe game and evaluate whether X or O won the game. The first number in the files represents the number of data sets to follow. Each data set will contain a 9 letter string. Each 9 letter string contains a complete tic tac toe game Sample Data: # of data sets in the file-5 OxoxxoxoO OxxOKOxoO xoxoooXXO Files Needed: TicTacToe.java TicTacToeRunner.java tictactoe.dat Sample Output x X X algorithm help X O C x wins harlzontally The determineWinner method goes through the matrix to find a winner. It checks for a horizontal winner first. Then, it checks for a vertical winner Lastly, It checks for a diagonal winner. It must also check for a draw. A draw occurs If neither player wins XO X cat's game -n winner! You will read in each game from a file and store each game in a matrix. The file will have multiple games in it o wins vertically x wins diagonally! X O X o 0 C o wins horiioncally! Lab GoalThis lab was designed to teach you how to use a matrix, an array of arrays Lab Description Read in the values for a tic tac toe game and evaluate whether X or O won the game. The first number in the files represents the number of data sets to follow. Each data set will contain a 9 letter string. Each 9 letter string contains a complete tic tac toe game Sample Data: # of data sets in the file-5 OxoxxoxoO OxxOKOxoO xoxoooXXO Files Needed: TicTacToe.java TicTacToeRunner.java tictactoe.dat Sample Output x X X algorithm help X O C x wins harlzontally The determineWinner method goes through the matrix to find a winner. It checks for a horizontal winner first. Then, it checks for a vertical winner Lastly, It checks for a diagonal winner. It must also check for a draw. A draw occurs If neither player wins XO X cat's game -n winner! You will read in each game from a file and store each game in a matrix. The file will have multiple games in it o wins vertically x wins diagonally! X O X o 0 C o wins horiioncally

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

Entity Alignment Concepts Recent Advances And Novel Approaches

Authors: Xiang Zhao ,Weixin Zeng ,Jiuyang Tang

1st Edition

9819942527, 978-9819942527

More Books

Students also viewed these Databases questions