Tic Tac Toe Java help!

Hi, I have been trying to create a simple Tic Tac Toe game using Java. I'm currently having problems as to how to create the board using arrays (sorry I don't understand them very well). All I have so far is this,

public class ticTacToe {

private int [] [] theBoard = new int [3] [3];

// *'N' is no winner

//'X' is X won

// 'O' is O won

// 'C' is a cat's game

public static char didSomeoneWin(int [] [] currentBoard)

{

int winForX = 8000, winForO = 1,checkIfItsAcatsGame = 1, product;

char winner = 'N';

for(int column = 0; column < 3; column++) // Check the columns

{

product = currentBoard [0] [column] * currentBoard [1] [column] * currentBoard [2] [column];

if(product == winForX) winner = 'X';

if(product == winForO) winner = 'O';

}

for(int row = 0; row < 3; row++) // Check the rows

{

product = currentBoard [row] [0] * currentBoard [row] [1] * currentBoard [row] [2];

if(product == winForX) winner = 'X';

if(product == winForO) winner = 'O';

}

product = currentBoard [0] [0] * currentBoard [1] [1] * currentBoard [2] [2]; // Check one diagonal

if(product == winForX) winner = 'X';

if(product == winForO) winner = 'O';

product = currentBoard [0] [2] * currentBoard [1] [1] * currentBoard [2] [0]; // Check the other diagonal

if(product == winForX) winner = 'X';

if(product == winForO) winner = 'O';

if(winner == 'N') // If nobody's won, Check for a cat's game

{

for(int row = 0; row < 3; row++)

{

for(int column = 0; column < 3; column++)

checkIfItsAcatsGame *=currentBoard [row] [column];

}

if(checkIfItsAcatsGame != 0) winner = 'C'; // any empty space is a zero. So product is zero if there is space left.

}

return winner;

public void markX(int row, int column)

{

myBoard [row] [column] = 20;

}

public void markO(int row, int column)

{

myBoard [row] [column] = 1;

}

That is all so far, could someone help me print out the board? And help me out on the arrays? I don't think they are quite right. Thanks in Advance!

Message was edited by:

matthews1.7.2.0

[2313 byte] By [matthews1.7.2.0a] at [2007-10-2 20:15:54]
# 1
Hi,Do you need a GUI ?If yes see http://java.sun.com/docs/books/tutorial/uiswing/index.htmlYou can also see this : http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-Printing.html about printing.--Marc ( http://jnative.sf.net)
mdentya at 2007-7-13 22:58:13 > top of Java-index,Java Essentials,New To Java...
# 2

void printBoard(){

for (int i=0; i<3; i++){

System.out.println(String.format("%0$c%1$c%2$c",

getChar(theBoard[i][0]), getChar(theBoard[i][1], getChar(theBoard[i][2]);

}

}

char getChar(int val){

if (val == 20)

return 'X';

if (val == 1)

return 'O';

return ' ';

}

BaltimoreJohna at 2007-7-13 22:58:13 > top of Java-index,Java Essentials,New To Java...