If I'm reading this correctly, then this is all you need to do.
import java.util.Random;
public class Dice {
int numOfSides;
Random rand;
public Dice(int numOfSides) {
this.numOfSides = numOfSides;
rand = new Random();
}
public int rollDie(){
return rand.nextInt(numOfSides);
}
}
If you need a main method then it would look like this:
import java.util.Random;
public class Dice {
int numOfSides;
Random rand;
public Dice(int numOfSides) {
this.numOfSides = numOfSides;
rand = new Random();
}
public static int rollDie(){
return rand.nextInt(numOfSides);
}
public static void main(String[] args){
Dice dice = new Dice(6);
System.out.println(dice.rollDie());
}
}