ok so where i put if (getObjects(Worm.class).size() == 0) it turns the area blue and the last thing under gets put in the blue with it and it says not a statement any ideas on what to do :import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class CrabWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class CrabWorld extends World
{
/**
* Constructor for objects of class CrabWorld.
*
*/
public CrabWorld()
{
super(560, 560, 1);
prepare();
}
/**
* Prepare the world for the start of the program. That is: create the initial
* objects and add them to the world.
*/
private void prepare()
{
Crab crab = new Crab();
addObject(crab, 257, 300);
Worm worm = new Worm();
addObject(worm, 392, 50);
Worm worm2 = new Worm();
addObject(worm2, 462, 264);
Worm worm3 = new Worm();
addObject(worm3, 425, 501);
Worm worm4 = new Worm();
addObject(worm4, 413, 227);
Worm worm5 = new Worm();
addObject(worm5, 427, 460);
Worm worm6 = new Worm();
addObject(worm6, 179, 488);
Worm worm7 = new Worm();
addObject(worm7, 246, 495);
Worm worm8 = new Worm();
addObject(worm8, 54, 443);
Worm worm9 = new Worm();
addObject(worm9, 88, 269);
Worm worm10 = new Worm();
addObject(worm10, 105, 193);
Worm worm11 = new Worm();
addObject(worm11, 103, 52);
Worm worm12 = new Worm();
addObject(worm12, 223, 109);
Worm worm13 = new Worm();
addObject(worm13, 280, 71);
Worm worm14 = new Worm();
addObject(worm14, 339, 195);
Worm worm15 = new Worm();
addObject(worm15, 525, 105);
Worm worm16 = new Worm();
addObject(worm16, 480, 400);
Worm worm17 = new Worm();
addObject(worm17, 130, 390);
Lobster lobster = new Lobster();
addObject(lobster, 112, 474);
Lobster lobster2 = new Lobster();
addObject(lobster2, 94, 112);
Counter counter = new Counter();
addObject(counter, 46, 53);
counter.setLocation(23, 22);
Worm worm18 = new Worm();
addObject(worm18, 336, 509);
Worm worm19 = new Worm();
addObject(worm19, 447, 143);
Worm worm20 = new Worm();
addObject(worm20, 490, 472);
}
private void addWorms()
{
if (getObjects(Worm.class).size() == 0)
Worm worm = new Worm();
addObject(worm, 392, 50);
Worm worm2 = new Worm();
addObject(worm2, 462, 264);
Worm worm3 = new Worm();
addObject(worm3, 425, 501);
Worm worm4 = new Worm();
addObject(worm4, 413, 227);
Worm worm5 = new Worm();
addObject(worm5, 427, 460);
Worm worm6 = new Worm();
addObject(worm6, 179, 488);
Worm worm7 = new Worm();
addObject(worm7, 246, 495);
Worm worm8 = new Worm();
addObject(worm8, 54, 443);
Worm worm9 = new Worm();
addObject(worm9, 88, 269);
Worm worm10 = new Worm();
addObject(worm10, 105, 193);
Worm worm11 = new Worm();
addObject(worm11, 103, 52);
Worm worm12 = new Worm();
addObject(worm12, 223, 109);
Worm worm13 = new Worm();
addObject(worm13, 280, 71);
Worm worm14 = new Worm();
addObject(worm14, 339, 195);
Worm worm15 = new Worm();
addObject(worm15, 525, 105);
Worm worm16 = new Worm();
addObject(worm16, 480, 400);
Worm worm17 = new Worm();
addObject(worm17, 130, 390);
Worm worm18 = new Worm();
addObject(worm18, 336, 509);
Worm worm19 = new Worm();
addObject(worm19, 447, 143);
Worm worm20 = new Worm();
addObject(worm20, 490, 472);
} }
it says that worm worm = newworm is not a statement any ideas on how to fix?