for(int i = 0; i < 100000; i++){ d.throwDice(); if(d.throwDice() == diceScore){ scoreCount += 1; }}此代码有两件事:
- 它调用时
throwDice
不带int
(您已将其定义为public int throwDice(int diceCount)
,因此必须给它一个int
) throwDice
每个循环调用两次
您可以这样解决:
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; }}


