I know that this question has been answered countless times, and I have read an unreasonable amount of articles on this! However, I can just not figure it out and would love any input for this. I am making a tic tac toe game and in my main function, I am calling for the user to input which square to play in. Rather than just entering "3" and hitting enter, you have to press enter twice. Heres the code:
int N = 0;
while(true) {
System.out.println("PLease choose a spot to place in (0 to quit): ");
if(input.hasNextInt())
{
N = input.nextInt();
}
else
{
input.nextLine();
System.out.println("That wasn't a number, please enter a number( 0 to quit)");
//continue;
}
if(N < 0 || N > 9)
{
System.out.println("That's not a valid choice, please pick another!");
//continue;
}
if (N != 0)
{
Person.BoardUpdater(N,Game.GameBoard, "O");
Comp.AI(Game.GameBoard, "O" , "X");
Game.draw(Game.GameBoard);
}
else
{
break;
}
}