public class Boy extends Actor { /** * Act - do whatever the Boy wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { checkKeys(); tryToEat(); } public void checkKeys() { if( Greenfoot.isKeyDown ( "left" )) { move (-6); } if( Greenfoot.isKeyDown ( "right" )) { move (6); } } public void tryToEat() { if (canSee(Cake.class) ) { eat(Cake.class); } } public void createNewCake() { Cake newCake; newCake = new Cake(); World world; world = getWorld(); world.addObject(newCake, 100, 100); } }