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

2013/5/17

WHATS WRONG

Avik Avik

2013/5/17

#
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class COI here. * * @author (your name) * @version (a version number or a date) */ public class COI extends animal { /** * Act - do whatever the COI wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { { public void moveCoins(int dx, int dy) { List<Coin> coins = getObjects(Coin.class); for (Coin coin : coins) { coin.setLocation(coin.getX() + dx, coin.getY() + dy); } } IT SAYS ILLEGAL START OF EXPRESSION
danpost danpost

2013/5/17

#
That is what happens when you place one method inside of another.
Avik Avik

2013/5/17

#
CAN YOU SEND ME THE CORRECT CODE? THANKS
Obliverate Obliverate

2013/5/17

#
Move moveCoins out of act(), and then call moveCoins from act().
danpost danpost

2013/5/17

#
There is no correct code for what you have given above. First, you are using an Object in the class that is not recognizable to the class. Second, you are using a method on an Actor object that is supposed to be executed on a World object. Finally, you have one method inside of another, which you cannot do in Java coding.
You need to login to post a reply.