This site requires JavaScript, please enable it in your browser!
Greenfoot back
Hello
Hello wrote ...

2016/1/26

class,interface, or enum expected HELP

Hello Hello

2016/1/26

#
I'm having this error code with this, I dont see whats wrong with it, please help. By the way it is happening at the bottom of the code.
import greenfoot.*;  // (Actor, World, Greenfoot, GreenfootImage)

public class CrabWorld extends World
{
    HealthBar healthbar = new HealthBar();
   
    /**
     * Create the crab world (the beach). Our world has a size 
     * of 560x560 cells, where every cell is just 1 pixel.
     */
    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,196,266);
        Lobster lobster = new Lobster();
        addObject(lobster,272,53);
        Lobster lobster2 = new Lobster();
        addObject(lobster2,417,340);
        Lobster lobster3 = new Lobster();
        addObject(lobster3,139,463);
        Worm worm = new Worm();
        addObject(worm,315,486);
        Worm worm2 = new Worm();
        addObject(worm2,282,354);
        Worm worm3 = new Worm();
        addObject(worm3,440,497);
        Worm worm4 = new Worm();
        addObject(worm4,463,227);
        Worm worm5 = new Worm();
        addObject(worm5,290,132);
        Worm worm6 = new Worm();
        addObject(worm6,110,105);
        Worm worm7 = new Worm();
        addObject(worm7,436,66);
        Worm worm8 = new Worm();
        addObject(worm8,64,260);
        addObject(healthbar, 200, 40);
    }
}
}  
danpost danpost

2016/1/26

#
Check your bracketing when you see that message. You have excess coding beyond the scope of the class (remove line 50).
You need to login to post a reply.