so i am trying to generate a random number of worms, choosing between 8-10 (so 8,9, & 10) when the world starts.
Here is my code I am using so far. Although I feel like "static int numWorms = Greenfoot.getRandomNumber(minWorms-maxWorms); is incorrect, from it not working.
public class CrabWorld extends World { static int xDimension = 800; // X Dimension of our World static int yDimension = 800; // Y Dimension of our World static int minWorms = 8; static int maxWorms = 10; static int numWorms = Greenfoot.getRandomNumber(minWorms - maxWorms); /** * Create the crab world (the beach). Our world has a size * of xDimension x yDimension cells, where every cell is just 1 pixel. */ public CrabWorld() { super(xDimension, yDimension, 1); // Populuate with a Crab in the the center of my world int crabXPosition = xDimension/2; int crabYPosition = yDimension/2; // Add my crab populateCrab(crabXPosition, crabYPosition); // Add some worms populateWorms(numWorms); } /** * Place a crab in the world at xPosition and yPosition */ private void populateCrab(int xPosition, int yPosition) { addObject(new Crab(), xPosition, yPosition); } /** * Place specified number of worms randomly in the world */ private void populateWorms(int numberOfWorms) { int loopNumber = 0; while (loopNumber < numberOfWorms) { // add a worm to the world, at a random location addObject(new Worm(), Greenfoot.getRandomNumber(xDimension), Greenfoot.getRandomNumber(yDimension)); loopNumber++; } } }