import java.util.Scanner;
public class ticTacToe
{
public static char[][] board = new char[3][3];
public static getMove(int turnNumber)
{
char choice = ' ';
if (turnNumber % 2 == 1)
{
//x's turn
System.out.println("X's Turn.");
char choice = 'x';
System.out.println("Which row and column would you like to choose? (enter number for row THEN column)");
Scanner input = new Scanner(System.in);
int rowChoiceX = input.nextInt();
int colChoiceX = input.nextInt();
board[rowChoiceX][colChoiceX] = choice;
}
else
{
//y's turn
System.out.println("O's Turn.");
char choice = 'y';
System.out.println("Which row and column would you like to choose? (enter number for row THEN column)");
Scanner input = new Scanner(System.in);
int rowChoiceY = input.nextInt();
int colChoiceY = input.nextInt();
board[rowChoiceY][colChoiceY] = choice;
}
}
public static void writeBoard()
{
if(turnNumber < 1)
{
char choice = ' ';
}
System.out.println("==ROWS=======================");
System.out.println("=====1=======2=======3=======");
System.out.println("C|| ||| ||| |||");
System.out.println("O|| "+choice+" ||| "+choice+" ||| "+choice+" |||");
System.out.println("L|1 ||| ||| |||");
System.out.println("U|| ||| ||| |||");
System.out.println("M============================");
System.out.println("N|| ||| ||| |||");
System.out.println("S|| "+choice+" ||| "+choice+" ||| "+choice+" |||");
System.out.println("||2 ||| ||| |||");
System.out.println("||| ||| ||| |||");
System.out.println("=============================");
System.out.println("||| ||| ||| |||");
System.out.println("||| "+choice+" ||| "+choice+" ||| "+choice+" |||");
System.out.println("||3 ||| ||| |||");
System.out.println("||| ||| ||| |||");
System.out.println("=============================");
System.out.println("=============================");
}
// public static boolean winner()
// {
// row checks
// column checks
//diagonal checks
//execute this code only if there is a draw
// }
public static void newGame()
{
}
}
public class ticTacToeDemo
{
//use a 3X3 array for the game board.
public static char[][] board = new char[3][3];
public static void main(String[] args)
{
ticTacToe game = new ticTacToe();
int turnNumber = 0;
game.newGame();
while(!game.winner())
{
turnNumber += 1;
game.writeBoard();
game.getMove();
}
}
}
i'm almost done with this program, but this one little snag is holding me back. after this i can finish the rest of the program.