我收到我無法修復的錯誤。我得到約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