我正在创造一个Tic Tac Toe游戏,这就是我正在检查胜利的方式。我在这段代码中得到了这个错误列表:
/tmp/java_hoEysf/TicTacToe.java:195:错误:不是声明公开 void Checkforwin(); ^ /tmp/java_hoEysf/TicTacToe.java:195:错误: ';'预期Public void Checkforwin(); ^ /tmp/java_hoEysf/TicTacToe.java:195:错误:表达式的非法启动Public void Checkforwin();
谁能告诉我我做错了什么? (代码不完整,我只是想知道为什么该方法不起作用。)
代码:
public void checkForWin() {
if (board [0][0] + board[0][1] + board[0][2] == 15) {
btnA3.setText("Ax");
win = 1;
}
if (board [0][0] + board[0][1] + board[0][2] == 30) {
btnA3.setText("Ao");
win = 2;
}
if (board[1][0] + board[1][1] + board[1][2] == 15) {
btnA3.setText("Ax");
win = 1;
}
if (board[1][0] + board[1][1] + board[1][2] == 30) {
btnA3.setText("Ao");
win = 2;
}
if (board[2][0] + board[2][1] + board[2][2] == 15) {
btnA3.setText("Ax");
win = 1;
}
if (board[2][0] + board[2][1] + board[2][2] == 30) {
btnA3.setText("Ao");
win = 2;
}
if (board[0][0] + board[1][0] + board[2][0] == 15) {
btnA3.setText("Ax");
win = 1;
}
if (board[0][0] + board[1][0] + board[2][0] == 30) {
btnA3.setText("Ao");
win = 2;
}
}