Organizing methods within classes in a simulation of a dice game

I had help writing this program as a simulation of a dice game, but I can’t seem to get it to run because of the syntax/bracket situation. I think I am having trouble organizing my methods within the classes. Any tips?

import java.util.Random;

public class diceGame 
{
    private class DiceRoll
    {
        public static Random rng = new Random();
        private int a, b, c; //rolls

        public DiceRoll()
        {
            this.a = rng.nextInt(6);
            this.b = rng.nextInt(6);
            this.c = rng.nextInt(6);
        }

        public int getScore()
        {
            if (a ==6 && b == 6 && c ==6)
            {
                return 500;
                System.out.println("Congratulations! You rolled three 6s! You just earned 500 points!!");
            }
            else if ((a == 6 && b == 6 && b != c) || (b == 6 && c == 6 && c !=a))
            {
                return 100;
                System.out.println("Congratulations! You rolled two 6s! You just earned 100 points!!");
            }
            else if ((a == b && b != c) || (b == c && c !=a))
            {
                return 50;
                System.out.println("Congratulations! You just earned 50 points!!");
            }
            else 
            {
                System.out.println("Nice Try!");
            }
        }

        public String toString()
        {
            return String.format("Rolled a %d, %d, and %d", a, b, c);
        }
    }

    public static void main (String args[])
    {
        DiceRoll d; 
        while (true)
        {
            d = new DiceRoll();
            d.getScore();        // gives you how much to change the player score
        }
        // finish client
    }
}


Source: syntax

Leave a Reply