I’m getting errors like this:
Test. java:8 :')' expected
Test. java: 8: error :illegal start of expression
Test. java:9 :')' expected
Test. java: 9: error :illegal start of expression
Lines 8 and 9 are:
blackjackplayer = checkForBlackJacks(BlackJackHand playerhand);
blackjackdealer = checkForBlackJacks(BlackJackHand dealerhand);
The class is:
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);
}
}
This is just a java file with the error parts in it. The real program has all the components.
When passing a value as a method parameter, you must only include the object’s name, not its type.