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

2013/7/10

Problem with my code

Dinokilla7 Dinokilla7

2013/7/10

#
My code is very basic and Im new to this, but it keeps saying "Reached end of file while parsing" And I have no idea what that means
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Ant here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Ant extends Actor
{
    /**
     * Act - do whatever the Ant wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        moveAndTurn();
        eat();
    }
    public void moveAndTrun()
    {
        move(4);
        
        if (Greenfoot.isKeyDown("a"))
        {
            turn(-5);
        }
        if (Greenfoot.isKeyDown("d"))
        {
            turn(5);
        }
    }
    public void eat()
    {
    
        Actor food;
        food = getOneObjectAtOffset(0,0, Food.class);
        if (food!=null)
        {
            World world;
            world = getWorld();
            world.removeObject(food);
        }
    }
    
        
      
Can someone tell me whats wrong?
Gevater_Tod4711 Gevater_Tod4711

2013/7/10

#
Your class is never closed. Try adding '}' at the end of your class. That may help.
You need to login to post a reply.