It comes down to your use of d
. You remembered to reset the value of c
, but not d
.
public static void q()
{
// Init variables
int[] x = new int[t];
c = 0;
d = 0;
while(c != t)
{
x[c] = roll(sides);
c++;
}
while(d != t)
{
System.out.println("You rolled " + x[d]);
d++;
}
}
There's no reason that c
and d
should be static class variables. Instead, you should just declare them right in your method call, like you do with x
:
public static void q()
{
// Init variables
int[] x = new int[t];
int c = 0;
int d = 0;
while(c != t)
{
x[c] = roll(sides);
c++;
}
while(d != t)
{
System.out.println("You rolled " + x[d]);
d++;
}
}