java修复int转换并为类添加一个返回
我已经完成了一个代码,但是有几个问题需要解决,但是,我尝试了许多不同的方法都不起作用,有人能在这里给我一些帮助吗
我的错误部分是total = getScore;
和return total;
。。。意思是不用担心,我相信这些是不必要的,也不正确的
public class Main {
public static void main(String[] args) {
int total;
boolean winLoss;
int win = 0;
int loss = 0;
int point = 0;
for(int i=0; i<100000;i++){
total = getScore();
if...
...
while(true){
total = getScore();
if(total == point){...
...
}
}
...
private static void getScore(){
int dice1 = (int)(Math.random()*(6-1)+1);
int dice2 = (int)(Math.random()*(6-1)+1);
int total = dice1+dice2;
return total;
}
}
# 1 楼答案
程序是错误的。怎么样?有一个方法返回类型为void,用于填充局部变量值
void getScore()
# 2 楼答案
函数
getScore()
的类型应为int