I REALLY need help. ThIs program works - except I have one fatal error that I can't seem to figure out how to fix. The players can play where other players have already played. I tried to use the switch statement at the bottom in method checkMove where if result == false, that spot is taken. But of course, anyone can see that that will not work. I have looked at other threads, but nome of them have seemed to conform to what I have here. If you can help me, PLEASE do! Thanks in advance!
import java.util.Scanner;
class Tic {
public static void main(String[] args) {
System.out.println("Welcome to Michaila's TicTacToe!");
Scanner xo = new Scanner(System.in);
char [][] tic = new char[3][3];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
tic[i][j] = ' ';
printMe(tic);
System.out.println("It is X's turn.");
boolean x = true;
int testing = 5;
for(int i = 1; i <= testing; i++){
if(x == true){
if(i >= 2){
System.out.println("It is X's turn. Please type a number (1-9).");
}//end if i>2
else{
System.out.println("Please type a number (1-9).");
}//end else
int numb = xo.nextInt();
if(checkMove(numb, tic) == false){
System.out.println("Taken! Please choose again (1-9).");
numb = xo.nextInt();
}//end if
while (numb >= 1 && numb <= 9){
xsmove(numb, tic, x);
break;
}//end while valid
while(numb < 1 || numb > 9){
System.out.println("That number is not valid. Please choose a number 1 - 9.");
numb = xo.nextInt();
xsmove(numb, tic, x);
}//end while not valid
printMe(tic);
System.out.println("Good move!");
x = false;
if(tic[0][0] == 'X' && tic[1][0] == 'X' && tic[2][0] == 'X'
|| tic[0][1] == 'X' && tic[1][1] == 'X' && tic[2][1] == 'X'
|| tic[0][2] == 'X' && tic[1][2] == 'X' && tic[2][2] == 'X'
|| tic[0][0] == 'X' && tic[0][1] == 'X' && tic[0][2] == 'X'
|| tic[1][0] == 'X' && tic[1][1] == 'X' && tic[1][2] == 'X'
|| tic[2][0] == 'X' && tic[2][1] == 'X' && tic[2][2] == 'X'
|| tic[0][0] == 'X' && tic[1][1] == 'X' && tic[2][2] == 'X'
|| tic[2][0] == 'X' && tic[1][1] == 'X' && tic[0][2] == 'X'){
System.out.println("X WINS!!! :)(: Game Over!!");
System.exit(0);
}//end long if x
else if(i == 5){
System.out.println("Draw!");
System.exit(0);
}//end else if
}//end if xtrue
if(x == false){
System.out.println("It is O's turn. Please type a number (1-9).");
int numb = xo.nextInt();
if(checkMove(numb, tic) == false){
System.out.println("Taken! Please choose again (1-9).");
numb = xo.nextInt();
}//end if
while (numb >= 1 && numb <= 9){
xsmove(numb, tic, x);
break;
}//end while valid
while(numb < 1 || numb > 9){
System.out.println("That number is not valid. Please choose a number 1 - 9.");
numb = xo.nextInt();
xsmove(numb, tic, x);
}//end while not valid
printMe(tic);
System.out.println("Good move!");
x = true;
if(tic[0][0] == 'O' && tic[1][0] == 'O' && tic[2][0] == 'O'
|| tic[0][1] == 'O' && tic[1][1] == 'O' && tic[2][1] == 'O'
|| tic[0][2] == 'O' && tic[1][2] == 'O' && tic[2][2] == 'O'
|| tic[0][0] == 'O' && tic[0][1] == 'O' && tic[0][2] == 'O'
|| tic[1][0] == 'O' && tic[1][1] == 'O' && tic[1][2] == 'O'
|| tic[2][0] == 'O' && tic[2][1] == 'O' && tic[2][2] == 'O'
|| tic[0][0] == 'O' && tic[1][1] == 'O' && tic[2][2] == 'O'
|| tic[2][0] == 'O' && tic[1][1] == 'O' && tic[0][2] == 'O'){
System.out.println("O WINS!!! :)(: Game Over!!");
System.exit(0);
}//end long if o
else if(i == 5){
System.out.println("Draw!");
System.exit(0);
}//end elseif
}//end if xfalse
}//end fortest
}//end main
private static void printMe(char [][]tic){
int numpad = 0;
System.out.println("-------\t\t-------");
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
System.out.print("|" + tic[i][j]);
}//end for j
System.out.print("|");
System.out.println("\t\t" + "|" + (numpad + 1) + "|" + (numpad + 2) + "|" + (numpad + 3) + "|");
System.out.println("-------\t\t-------");
numpad += 3;
}//end for i
}//end printMe
public static void xsmove (int numb, char[][] tic, boolean x){
switch (numb){
case 1: if(tic[0][0] == ' ' && x == true) tic[0][0] = 'X';
else tic[0][0] = 'O'; break;
case 2: if(tic[0][1] == ' ' && x == true) tic[0][1] = 'X';
else tic[0][1] = 'O'; break;
case 3: if(tic[0][2] == ' ' && x == true) tic[0][2] = 'X';
else tic[0][2] = 'O'; break;
case 4: if(tic[1][0] == ' ' && x == true) tic[1][0] = 'X';
else tic[1][0] = 'O'; break;
case 5: if(tic[1][1] == ' ' && x == true) tic[1][1] = 'X';
else tic[1][1] = 'O'; break;
case 6: if(tic[1][2] == ' ' && x == true) tic[1][2] = 'X';
else tic[1][2] = 'O'; break;
case 7: if(tic[2][0] == ' ' && x == true) tic[2][0] = 'X';
else tic[2][0] = 'O'; break;
case 8: if(tic[2][1] == ' ' && x == true) tic[2][1] = 'X';
else tic[2][1] = 'O'; break;
case 9: if(tic[2][2] == ' ' && x == true) tic[2][2] = 'X';
else tic[2][2] = 'O'; break;
}//end switch
}//end xsmove
public static boolean checkMove (int numb, char[][] tic){
boolean result = true;
switch (numb){
case 1: if (tic[0][0] != ' ') result = false; break;
case 2: if (tic[0][1] != ' ') result = false; break;
case 3: if (tic[0][2] != ' ') result = false; break;
case 4: if (tic[1][0] != ' ') result = false; break;
case 5: if (tic[1][1] != ' ') result = false; break;
case 6: if (tic[1][2] != ' ') result = false; break;
case 7: if (tic[2][0] != ' ') result = false; break;
case 8: if (tic[2][1] != ' ') result = false; break;
case 9: if (tic[2][2] != ' ') result = false; break;
}//end switch
return result;
}//end checkMove
}//end class