I'm working on a dice roller (for fun and knowledge). I have a question about the following code. This snippet is meant to be a basic menu that will prompt the user for a number of dice as the number of sides on each one (which will be fed into an array (number of dice) and a random number generator (sides).
publicint menu()
{
int sds = 0;
int dic = 0;
do
{
System.out.print("How many sides does your die have? ");
sds = sc.nextInt();
System.out.println("");
System.out.print("How many dice am I rolling, here? ");
dic = sc.nextInt();
}
while (sds > 0 && dic > 0);
return sds;
return dic;
}
When I try to compile it I get "unreachable statment" at 'return dic;'. if I remove 'return dic;' the program compiles ust fine, but I'm iffy on the return statment and it's function. Will I be able to call these variables later without it? And if so, why do I have the previous statment?
Is the situation that I should have 2 sections here? One for the sides and one for the number of dice, each returning one variable?
Nevermid, I believe I answered my own question at the bottom there. Two different constructors. What was throwing me off was that I envisioned the printed text as being part of a unified whole, but what I needto see what was it was broken by user input.