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

2019/9/10

doing Greenfoot book exercise getting error at the end

KIOP KIOP

2019/9/10

#
import greenfoot.*;

/**
 * This class defines a crab. Crabs live on the beach.
 */
public class Crab extends Actor
{
    public void act()
    {
    if ( isAtEdge() )
    {
      turn(17);   
    }
    if ( Greenfoot.getRandomNumber(100) < 10 )
  {
    turn(Greenfoot.getRandomNumber(90)-45);
  }

  move(5);
  lookForWorm(); 
}

/**
 * check whether we have stumbled upon a worm.
 * If we have, eat it. If not, do nothing
 */
public void lookForWorm()
{
   if ( isTouching(Worm.class) )
   {
      removeTouching(Worm.class);
   }
}
danpost danpost

4 days ago

#
There is no end to your class (no bracket to pair up with the one on line 7).
You need to login to post a reply.