gpt4 book ai didi

java - 编译错误 : Missing return statement

转载 作者:行者123 更新时间:2023-11-29 09:35:34 26 4
gpt4 key购买 nike

<分区>

这个程序用 3 种不同的方法玩花旗骰。我在玩掷骰子时需要帮助,但我需要使用这 3 种不同的方法,但出于某种原因,每次我编译时都会收到此错误:

CrapsAnalysis.java:48: error: missing return statement
}
^
1 error
Process javac exited with code 1

代码:

public class CrapsAnalysis
{
public static int rollDie( int n) {
return (int)(Math.random()*n) + 1 ;
}
public static int rollDice( ) {
return rollDie(6) + rollDie(6) ;
}
public static boolean playOneGame( ) {
int newDice = rollDice();
int roll = rollDice(); //first roll of the dice
int playerPoint = 0; //player point if no win or loss on first roll
if (roll == 7 || roll == 11)
return true;
else if (roll == 2 || roll == 3 || roll == 12)
return false;
else
playerPoint = roll;
do {
if (rollDice() == 7)
return false;
else if (rollDice() == playerPoint)
return true;
else
newDice = rollDice();
} while (rollDice() != playerPoint || rollDice() != 7) ;
}
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com