我收到我无法修复的错误。我得到约8个错误在这些行:java applet的错误
if (weight [1] + weight[4] + weight[7] == twoWeights){
if(weight[1]==0){
return 1;
else if (weight [4] == 0)
return 4;
else
return 7;
}
if (weight [2] + weight[5] + weight[8] == twoWeights){
if(weight[2]==0)
return 2;
else if (weight [5] == 0)
return 5;
else
return 8;
}
if (weight [0] + weight[4] + weight[8] == twoWeights){
if(weight[0]==0)
return 0;
else if (weight [4] == 0)
return 4;
else
return 8;
}
if (weight [2] + weight[4] + weight[6] == twoWeights){
if(weight[2]==0)
return 2;
else if (weight [4] == 0)
return 4;
else
return 6;
}
return -1;
}
int getRandomSquare(){
boolean gotEmptySquare = false;
int selectedSquare = -1;
do {
selectedSquare = (int) (Math.random() * 9);
if (squares[selectedSquare].getLabel().equals("")){
gotEmptySquare = true;
}
}
while (!gotEmptySquare);
return selectedSquare;
}
void highlightWinner(int win1; int win2; int win3) {
squares [win1].setBackground(Color.CYAN);
squares [win2].setBackground(Color.CYAN);
squares [win3].setBackground(Color.CYAN);
}
void endTheGame(){
newGameButton.setEnabled(true);
for(int i=0;i<9;i++){
squares[i].setEnabled(false);
}
}
}
}
的错误是:
TicTacToe.java:213: '别人' 没有 '如果' 否则如果(重量[4 ] == 0) ^
TicTacToe.java:256:';'预期INT getRandomSquare(){ ^
TicTacToe.java:269:表达的非法起动空隙 highlightWinner(INT WIN1; INT WIN2; INT WIN3){^
TicTacToe.java:269: ';'预期的空虚highlightWinner(int win1; int win2; int win3){ ^
TicTacToe.java:269:';'预期空隙highlightWinner(INT WIN1; INT WIN2; INT WIN3){ ^
TicTacToe.java:274:表达空隙endTheGame的非法起动(){ ^
TicTacToe.java:274:“; “预期空隙endTheGame(){ ^
你必须更仔细地阅读异常跟踪,你将能够解决所有问题。 – alnasfire 2013-02-10 19:48:16