I am trying to learning java, by goofing around and creating different things such as this dice example. However, in the class below I am stuck on this missing return, but I am not sure why. All help is appreciated!
Test1.java:12: error: missing return statement } ^ 1 error
import java.util.Random;
class Char
{
Random r = new Random();
int nSides;
public int Die(int sides)
{
this.nSides = sides;
r = new Random();
}
public int roll()
{
return r.nextInt(nSides + 1);
}
public int roll(int times)
{
int sum = 0;
for (int i = 0; i < times; i++)
{
sum += roll();
}
return sum;
}
}