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.

change this code

public static getMove(int turnNumber)
{

to this maybe

public static [B][U]void[/U][/B] getMove(int turnNumber)

note: mark as solved if this fixed it

Edited 6 Years Ago by phoenix911: n/a

change this code

public static getMove(int turnNumber)
{

to this maybe

public static [B][U]void[/U][/B] getMove(int turnNumber)

note: mark as solved if this fixed it

--------------------Configuration: <Default>--------------------
H:\Java Progs\ticTacToe.java:17: choice is already defined in getMove(int)
char choice = 'x';
^
H:\Java Progs\ticTacToe.java:30: choice is already defined in getMove(int)
char choice = 'y';
^
H:\Java Progs\ticTacToe.java:43: cannot find symbol
symbol : variable turnNumber
location: class ticTacToe
if(turnNumber < 1)
^
H:\Java Progs\ticTacToe.java:51: cannot find symbol
symbol : variable choice
location: class ticTacToe
System.out.println("O|| "+choice+" ||| "+choice+" ||| "+choice+" |||");
^
H:\Java Progs\ticTacToe.java:51: cannot find symbol
symbol : variable choice
location: class ticTacToe
System.out.println("O|| "+choice+" ||| "+choice+" ||| "+choice+" |||");
^
H:\Java Progs\ticTacToe.java:51: cannot find symbol
symbol : variable choice
location: class ticTacToe
System.out.println("O|| "+choice+" ||| "+choice+" ||| "+choice+" |||");
^
H:\Java Progs\ticTacToe.java:56: cannot find symbol
symbol : variable choice
location: class ticTacToe
System.out.println("S|| "+choice+" ||| "+choice+" ||| "+choice+" |||");
^
H:\Java Progs\ticTacToe.java:56: cannot find symbol
symbol : variable choice
location: class ticTacToe
System.out.println("S|| "+choice+" ||| "+choice+" ||| "+choice+" |||");
^
H:\Java Progs\ticTacToe.java:56: cannot find symbol
symbol : variable choice
location: class ticTacToe
System.out.println("S|| "+choice+" ||| "+choice+" ||| "+choice+" |||");
^
H:\Java Progs\ticTacToe.java:61: cannot find symbol
symbol : variable choice
location: class ticTacToe
System.out.println("||| "+choice+" ||| "+choice+" ||| "+choice+" |||");
^
H:\Java Progs\ticTacToe.java:61: cannot find symbol
symbol : variable choice
location: class ticTacToe
System.out.println("||| "+choice+" ||| "+choice+" ||| "+choice+" |||");
^
H:\Java Progs\ticTacToe.java:61: cannot find symbol
symbol : variable choice
location: class ticTacToe
System.out.println("||| "+choice+" ||| "+choice+" ||| "+choice+" |||");
^
12 errors

this should help u somewhat more.. errorless

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(turnNumber,game.getMove(turnNumber));
		}
	}
}

and here

import java.util.Scanner;


public class ticTacToe

{
	public static char[][] board = new char[3][3];
	
	public char getMove(int turnNumber)
	{
		char choice = ' '; 
			if (turnNumber % 2 == 1)
			{
				//x's turn
				System.out.println("X's Turn.");
				
				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.");
				
				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;
			}
			return choice;
		}
		
	
	public void writeBoard(int turnNumber, char choice)
	{
		if(turnNumber < 1)
		{
			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 boolean winner()
	{
		return false;
		// row checks
		
		// column checks
		
		//diagonal checks
		
		//execute this code only if there is a draw
		
	}
	
	public void newGame()
	{
		
	}
	
}

although theres a small problem with your app... ill identify it... but not solve it for you... ill help though...

everytime the user selects a region to put their symbol... it replaces all the regions with that players symbol (x or y)

ur output would need to be like this

board [0][0] || board [0][1] || board [0] [2]
board [1][0] || board [1][1] || board [1][2]

etc
and also do error checking... making sure the user doesnt enter n range outside the 3 x 3... remember arrays start at 0... so if the user select coloumn 3 and row 3... it will throw an exception... so take the results and - 1 from it...

Edited 6 Years Ago by phoenix911: n/a

attached is a copy of a working tic tac toe which i completed, and used the code from the OP..

with some changes of my own... note that this code can be simplified/made more efficient... but i 1str worked on getting it right

Edited 6 Years Ago by phoenix911: n/a

This question has already been answered. Start a new discussion instead.