我收到这样的错误:
Test. java:8 :')' expected
Test. java: 8: error :illegal start of expression
Test. java:9 :')' expected
Test. java: 9: error :illegal start of expression
第 8 行和第 9 行是:
blackjackplayer = checkForBlackJacks(BlackJackHand playerhand);
blackjackdealer = checkForBlackJacks(BlackJackHand dealerhand);
课程是:
public class Test{
public void playround (){
int temp = -1;
playerhand = new BlackJackHand(22);
dealerhand = new BlackJackHand(22);
addCards(playerhand, 2);
addCards(dealerhand, 2);
blackjackplayer = checkForBlackJacks(BlackJackHand playerhand);
blackjackdealer = checkForBlackJacks(BlackJackHand dealerhand);
while(temp!=2&&playerhand.gettotal()<=21){
printHands(false, true, true);
temp = Prompt.getInt("\nPress 1 to hit, or 2 to stand. ", 1, 2);
if (temp==1&&playerhand.gettotal()<=21){
addCards(playerhand,1);
}
}
if (playerhand.gettotal()>21){
playerbust = true;
}
else{
seeWhoWon();
}
//done = true;
}
public boolean checkForBlackJacks (BlackJackHand x){
return (x.gettotal()==21&&x.getmyhand().size()==2);
}
}
这只是一个包含错误部分的 java 文件。真正的程序具有所有组件。