I am very very very new to
Java and have been struggling for days and just don't seem to understand.
I need to:
1. Create a class named Die to store data about each die. This class should contain these constructors and methods:
public Die() //default to 6 sided die
public Die(int sides) //allow a variable number of sides
public void roll()
public int getValue()
2. Create a class named PairOfDice to stre two dice. This class should contain two instance variables of the Die type, an instance variable that holds the sum of the two dice, and these constructors and methods:
public PairOfDice() //default to six sided dice
public PairOfDice (int sides) //allow a variable number of sides
public void roll()
public int getValue1() // get value of die1
public int getValue2() // get value of die2
public int getSum() // get the sum of both dice
Use the ramdon method of the Math calss to generate a random number from 1 to the number of sides on a die like this:
int value = (int) (Math.randon() * sides);
3. Create a class named PairOfDice class to roll the dice. This class should display special messages for craps, snake eyes and box cars. Assume that two six sided dice are used.
If anyone could help me understand this concept and how to get started I would appreciate it! It's due sunday night.