更新时间:2022-06-23 16:52:34
for(int i = 0; i < 100000; i++){
d.throwDice();
if(d.throwDice() == diceScore){
scoreCount += 1;
}
}
此代码有两点错误:
int
的throwDice
(您已将其定义为public int throwDice(int diceCount)
,因此必须给它一个int
)throwDice
两次throwDice
without an int
(you have defined it as public int throwDice(int diceCount)
, so you must give it an int
)throwDice
twice each loop您可以这样解决它:
for(int i = 0; i < 100000; i++){
int diceResult = d.throwDice(diceCount); // call it with your "diceCount"
// variable
if(diceResult == diceScore){ // don't call "throwDice()" again here
scoreCount += 1;
}
}