Ich bin neu in Java und das ist, was ich zu tun habe:Würfel eine bestimmte Anzahl von Malen Java
Wenn ein Spieler auf 2 Würfel 5-mal in 1 Runde Doppel-Sechser bekommt, eine Zufallszahl zwischen 10 und 30 ist ausgewählt. Zum Beispiel, wenn diese Zahl 20 ist, sollten die anderen zwei Würfel zwanzig Mal gerollt werden und du multiplizierst die zwei Zahlen und erhältst das kumulative Produkt.
Dies ist nur ein kleiner Teil des großen Programm und das ist, was ich bisher getan haben:
if (ninedice == 6 && sixdice == 6) {
rolledDoubleSix++;
if (rolledDoubleSix == 5) {
dicerolls = (int) Math.ceil(Math.random() * (30 - 10 + 1) + 10);
int ninediceproduct = dicerolls;
int sixdiceproduct = dicerolls;
if (ninediceproduct > 0) {
ninediceproduct=(int)Math.ceil(Math.random() * 9);
}
if (sixdiceproduct > 0) {
sixdiceproduct = dicerolls * (int) Math.ceil(Math.random() * 6);
}
int cumulativetotal = 0;
int cumulative = sixdiceproduct * ninediceproduct;
cumulativetotal = cumulativetotal + cumulative;
accountpoints = accountpoints + cumulativetotal;
accountptsoutput.setText("" + accountpoints);
Das Problem, das ich ist, dass ich weiß nicht, wie die beiden Würfel eine bestimmte rollen zu machen Anzahl. Wenn die Zufallszahl zwischen 10 und 30 18 ist, wie lasse ich diese Würfel 18 Mal rollen?
Haben Sie gelernt, über „for-Schleifen“ noch? –
Nicht viel. Aber wie kann das helfen? –
Nun, eine "for-Schleife" lässt Sie immer wieder etwas wiederholen. Es scheint, als ob du hier einen haben möchtest. Daher würde ich empfehlen, sie im Online-Java-Lernprogramm von Oracle zu lesen. –