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;
}
}
您好!以上是我的代碼來確定數組(列)是否已滿,如果它已滿,用戶應該提示再次移動。連接4 Java項目 - 確定列滿時的問題
但是我有一個問題,程序發現它已滿,提示用戶,並且在用戶進行有效的移動之後,程序不會移動玩家(從玩家1-2-2-2等) )。
有什麼建議嗎?
這不是完整的代碼...爲了幫助你,通過提供完整的代碼來幫助我們。 –