在此代码的最后一行,我收到错误,无法找到符号钱包。任何帮助将不胜感激。
int money = money();
boolean again = again("Ready");
do {
int bet = bet(money);
int wallet = wallet(bet);
Deck deck = dealDeck();
int com = comDeal(deck);
int user = userDeal(deck);
int userTotal = userHit(user, deck);
int comTotal = comHit(com, deck, userTotal);
int winner = whoWon(userTotal, comTotal);
again = again("Play again");
}
while (again && wallet > 0);
最佳答案
int wallet
是在 do-while
循环内定义的。不允许在其外部使用它,就像在 while
的情况下一样,因为它超出了范围。
只需在 do-while
循环之前声明此变量即可:
int money = money();
int wallet = 0;
boolean again = again("Ready");
do {
//rest of code here...
} while (<condition>);
关于Java 在 Do 循环中找不到符号错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27530431/