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

2016/8/11

i keep on getting class interface,or enum expected

sharktank sharktank

2016/8/11

#
import greenfoot.*; Bullets bullets = new Bullets(); /** * Write a description of class bullets here. * * @author (your name) * @version (a version number or a date) */ public class bullets extends Actor { /** * Act - do whatever the bullets wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { move(10); { fireOnCommand(); } if(Greenfoot.isTouching(apple.class)) { removeTouching(alligator.class) World myWorld = getWord(): myWorld.removeObject (this); } } public void actfireOnComand() { if(Greenfoot.isKeyDown("f")); { World myWorld = getWorld(); myWorld.addObject(bullets, 0,0); bullets.setLocation (getX(), getY()); bullets.setRotation (getRotation()); } } }
danpost danpost

2016/8/11

#
The second line in your code is misplaced. It should be in the incorrectly named 'actFireOnCommand' method, inside the 'if' block as the first or second line there. The compiler does not expect to find that line where you had it and throws the error as a result (the only thing allowed outside the class code are import statements).
You need to login to post a reply.