So I want a loop to prepare all the stuff I have in my world in a random place and one class with a random number of that
class in the world but I can't find a loop method that may help? Have I over looked a loop?


1 2 3 | for ( int i = 0 ; i < numberOfActors; i++) { addObject( new YourActor(), Greenfoot.getRandomNumber(getWidth()), Greenfoot.getRandomNumber(getHeight())); } |
1 2 3 4 | int randomNumber = Greenfoot.getRandomNumber( 10 ); //add something between 0 and 9 actors; for ( int i = 0 ; i < randomNumber; i++) { addObject( new YourActor(), Greenfoot.getRandomNumber(getWidth()), Greenfoot.getRandomNumber(getHeight())); } |