if (count % 2 == 0) {
int columnMove;
System.out.print("Player one, please enter a move or q to quit: ");
columnMove = scan.nextInt() - 1;
if (columnMove <= columns - 1 && columnMove >= 0) {
turns = true;
game.playerOnePrompt(board, columns, rows, columnMove);
++count;
if (board[0][columnMove] != "_") {
System.out.println("This column is full");
count = 0;
}
} else {
System.out.println("Invalid move");
count = 0;
}
} else {
int columnMove;
System.out.print("Player two, please enter a move: ");
columnMove = scan.nextInt() - 1;
if (columnMove <= columns - 1 && columnMove >= 0) {
turns = true;
game.playerTwoPrompt(board, columns, rows, columnMove);
count++;
if (board[0][columnMove] != "_") {
System.out.println("This column is full");
count = 1;
}
} else {
System.out.println("Invalid move");
count = 1;
}
}
你好!以上是我确定数组(列)是否已满的代码,如果已满,则应提示用户进行另一次操作。
但是我遇到了一个问题,程序看到它已满,提示用户,并且在用户进行有效移动后,程序不会转移玩家(从玩家 1 - 2 - 1 - 2 等)。
有什么建议吗?