好的,所以我正在为 Yahtzee 游戏编写一个程序,我试图弄清楚如何将每一轮的值存储在该轮记分卡框中,并继续填写记分卡的其他部分。我这样做的方式是通过我的代码的这一部分:
public static void finalScoreCard(int choice, int points)
{
int ones = one(choice, points);
int twos = two(choice, points);
int threes = three(choice, points);
int fours = four(choice, points);
int fives = five(choice, points);
int sixes = six(choice, points);
int threeKind = nine(choice, points);
int fourKind = ten(choice, points);
int fullHouse = eleven(choice, points);
int smallStr = twelve(choice, points);
int largeStr = thirteen(choice, points);
int yahtzee = fourteen(choice, points);
int chance = fifteen(choice, points);
}
public static int one(int choice, int points)
{
final int score;
if (choice == 1)
score = points;
if (choice != 1 && score != points)
return 0;
else
return score;
}
所以“one”方法应该接受选择数和点参数,如果选择了该框,则返回分数。如果用户选择该选项,我希望我的程序实例化“score”,并用“points”分配“score”。然后在他们完成此操作后,该方法应该在每轮之后返回分数,或者返回 0 直到“分数”被实例化。问题是,我不明白如何多次保存“分数”的值。整个程序处于一个运行 13 次的 for 循环中。谢谢