Suppose I wanted to get a random number that is either: 160, 320, or 480. How would I go about only picking one of those numbers at random? Thank you.
public int randomNumber(Random RNG, int multiple, int max) {
return RNG.nextInt(max) * multiple;
}
or
public int randomNumber(int[] set, Random RNG) {
return set[RNG.nextInt(set.length)];
}
Something like that?
If you’re looking for something like the second option, then you could even go more generic
public <T> T randomNumber(T[] set, Random RNG) {
return (T) set[RNG.nextInt(set.length)];
}
:-* Thank you. :-* :-* :-* :-* :-* :-* :-*