i am trying to make it so that my crab generates the worms at random locations.... this is my code so far.
in crab class
in my world class
/**
* special constructor that also sets num of worms
*/
public Crab(int numWorms) //self note, this is a constructor.
{
setNumberOfWorms(numWorms);
setImages();
}
/**
* set the number of worms in the world
*/
public void setNumberOfWorms(int numWorms)
{
if (numWorms > 0)
{
wormsInWorld = numWorms;
}
}static int numWorms = Greenfoot.getRandomNumber(maxWorms-minWorms+1)+minWorms;
// Add my crab
populateCrab(crabXPosition, crabYPosition); /**
* Place a crab in the world at xPosition and yPosition
*/
private void populateCrab(int xPosition, int yPosition)
{
Crab myCrab = new Crab(numWorms);
addObject(myCrab, xPosition, yPosition);
}
