我正在写一个TicTacToe游戏,它反复提示用户移动.它要求选择超过9次,我不知道为什么.
我的设计有一个二维数组来存储有关电路板当前状态的信息,使用JOptionPane要求用户选择电路板(左上1个,中上2个,右上3个,左中4个,等等).每次移动后,将当前板输出到控制台.如果已使用某个位置,请再次提示用户.(没有必要进行胜利者检查,因为我们被告知要再次这样做.
这是我的整个代码:
import javax.swing.JOptionPane;
// Basic TicTacToe game.
public class TicTacToe1 {
public static void main(String[] args){
// Hello there!
Object[] options = { "I'm ready to play!",};
Object[] options2 = { "Select another number.",};
JOptionPane.showOptionDialog(null,"To play TicTacToe, use the numbers 1 to 9 to choose where you place a mark. Are you ready?","TicTacToe1",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
// Define the board.
char board[][] = new char[3][3];
// Zero out the board.
for(int a=0; a<3; a++) {
for(int …Run Code Online (Sandbox Code Playgroud) java ×1