import java.util.Random;
/*
by "hfkmfn" for "seidoken", Fri, Oct 26th, 2018
see: https://voat.co/v/programming/2807178
based on: https://justpaste.it/5v26y
*/
public class Bunco
{
static int doRound(int roundNum)
{
Random dice = new Random();
int x = dice.nextInt(6) + 1;
int y = dice.nextInt(6) + 1;
int z = dice.nextInt(6) + 1;
System.out.println();
System.out.print("You rolled a " + x + " and a " + y + " and a " + z);
int score = x + y + z;
/* apply roll score bonuses if any */
if(x == y && y == z && z == x)
{
if(x == roundNum) { score += 21; System.out.print(": BUNCO!"); }
else { score += 5; System.out.print(": mini-BUNCO!"); }
}
else
{
/* these stack if two occur, the case of three was handled above */
if(x == roundNum) score++;
if(y == roundNum) score++;
if(x == roundNum) score++;
}
System.out.println();
return score;
}
public static void main(String[] args)
{
int ROUNDS = 6;
int total = 0;
for(int i = 1; i <= ROUNDS; i++)
{
int score = doRound(i);
System.out.println("Your score for round " + i + " is " + score);
total += score;
}
System.out.println("========================");
System.out.println("Score for all rounds is " + total);
}
}