I've been messing around for the last few hours or so trying to utilize the Random class to no avail :confused:. What I'm trying to do is write a method that will call nextInt() after the previous run of it has selected a number. Let me show you in code:
Random generator = new Random();
static void genNumb() {
generator.nextInt();
}
int events = 0;
while (events < 10) {
genNumb();
System.out.println("Something happened!");
}
if(events == 10) {
break;
}
But the problem I am encountering is nextInt() doesn't seem to be grabbing a number. It will just flood the output all at once with "Something happened!". What I want to happen is an event will happen after genNumb has selected a number and then print out "Something happened". I don't want it to happen all at once, I want it to happen randomly (hence the reason I'm using random).
I've been up for 17 hours so I apologize if my intentions aren't very clear. I'll be more than happy to specify additional information/clarification after I get some sleep :closedeyes:.
Thanks.


Sign In
Create Account


Back to top









