the question is 1) build a Die class (6 sided). Then create a driver that tests your class. Start with one die in your driver then add a second die and notify the user and count when he or she rolls 7, 11, or a double. When the user is done rolling, output the results of the session.
Create a child class from the Die class called MultisidedDie. This die should allow the programmer using the class to decide how many sides the die has.
so far i have
- import java.util.Random;
-
-
public class DiceTest
-
{
-
int num;
-
int sides;
-
-
Dice()
-
{
-
num = 1;
-
sides = 6;
-
}
-
-
Dice(int number)
-
{
-
num = 1;
-
sides = 6;
-
if(number > 1)
-
{
-
num = number;
-
}
-
}
-
-
Dice(int number, int num_sides)
-
{
-
num = 1;
-
sides = num_sides;
-
if(number > 1)
-
{
-
num = number;
-
}
-
}
-
-
int roll()
-
{
-
java.util.Random r = new java.util.Random();
-
int sum = 0;
-
for(int i = 0; i < num; i++)
-
{
-
sum += r.nextInt(sides)+1;
-
}
-
return sum;
-
}
-
}
however when i compile i get a "invalid method declaration; return type required" on line 8,14,24....any advice or help woud be greatly aprecciated!!!