I got this method called diceThrow which returns a random number limited to the input given:
public static int diceThrow(int sides){
Random random = new Random();
int answ = random.nextInt(sides) + 1;
return answ;}
My program gives it values from 2 to 100, so for memory's sake I changed it's int types to byte types but it throws:
error: cannot find symbol
byte answ = random.nextByte(sides) + 1;
^
the modified method is like so:
public static byte diceThrow(byte sides){
Random random = new Random();
byte answ = random.nextByte(sides) + 1;
return answ;}
Aucun commentaire:
Enregistrer un commentaire