When I place the "return true" statement in this position,It gives me an unreachable statement error, however when i place it in this postion,
It never returns true. Any help is appreciated.
public boolean eat()
{
Food f1 = new Food();
Actor f;
f = getOneObjectAtOffset(0, 0, Food.class);
if (f != null)
{
return true;
World world;
world = getWorld();
world.removeObject(f);
getWorld().addObject(f1, (int)(Math.random()*36+1), (int)(Math.random()*25+1));
foodEaten += 1;
}
else
return false;
} public boolean eat()
{
Food f1 = new Food();
Actor f;
f = getOneObjectAtOffset(0, 0, Food.class);
if (f != null)
{
World world;
world = getWorld();
world.removeObject(f);
getWorld().addObject(f1, (int)(Math.random()*36+1), (int)(Math.random()*25+1));
foodEaten += 1;
return true;
}
else
return false;
}

