したがって、スキャナーを使用して3つの個別のユーザー入力、2つのint、および1つの文字列を入力するループがあります。intは問題なく機能しますが、文字列入力は機能しません。文字列のiputをスキップし、ループしてintを再度要求します。
for(int e = 10; e > 5; e++)
{
System.out.println("Enter the Y coordinate of your guess. The upper left corner is 0, and the lower left is 7");
int guessY = inputDevice.nextInt();
System.out.println("Enter the X coordinate of your guess. The upper left corner is 0, and the upper right is 7");
int guessX = inputDevice.nextInt();
display[guessX][guessY] = map[guessX][guessY];
for(int j = 0; j < 8; j++)
{
for(int t = 0; t < 8; t++)
{
System.out.print(display[j][t] + " ");
}
System.out.println();
}
System.out.println("Enter go when you are ready to make another move.");
System.out.println("Enter quit to give up");
String cont = inputDevice.nextLine();
if(cont.equalsIgnoreCase("quit"))
{
System.out.println("Weenie.");
System.exit(0);
} else if(cont.equalsIgnoreCase("go")) {
for(int i = 0; i < 100; i++)
System.out.println("\b");
}
if(map[guessX][guessY] == '0')
{
if(map[guessX - 1][guessY - 1] == '0')
display[guessX - 1][guessY - 1] = map[guessX - 1][guessY - 1];
if(map[guessX - 1][guessY + 0] == '0')
display[guessX - 1][guessY + 0] = map[guessX - 1][guessY + 0];
if(map[guessX - 1][guessY + 1] == '0')
display[guessX - 1][guessY + 1] = map[guessX - 1][guessY + 1];
if(map[guessX + 0][guessY - 1] == '0')
display[guessX + 0][guessY - 1] = map[guessX + 0][guessY - 1];
if(map[guessX + 0][guessY + 1] == '0')
display[guessX + 0][guessY + 1] = map[guessX + 0][guessY + 1];
if(map[guessX + 1][guessY - 1] == '0')
display[guessX + 1][guessY - 1] = map[guessX + 1][guessY - 1];
if(map[guessX + 1][guessY + 0] == '0')
display[guessX + 1][guessY + 0] = map[guessX + 1][guessY + 0];
if(map[guessX + 1][guessY + 1] == '0')
display[guessX + 1][guessY + 1] = map[guessX + 1][guessY + 1];
}
if(display[guessX][guessY] == 'M')
{
System.out.println("You hit a mine");
System.out.println("Game over.");
System.exit(0);
}
}