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

2013/12/26

heyy, why is this wrong

alosh alosh

2013/12/26

#
{ public void act() { if ( atWorldEdge( )) { turn(17); } move(); } }
danpost danpost

2013/12/26

#
There is no way to determine why it is wrong without seeing the class code in its entirety. Also, most helpful would be what error message you are getting, if any.
lordhershey lordhershey

2013/12/26

#
Don't you need a number parameter in the move call?
danpost danpost

2013/12/26

#
lordhershey wrote...
Don't you need a number parameter in the move call?
One of the reasons I asked that the entire class be shown was to see if there was a 'move' method within the class itself (that 'move' was not trying to call the Actor class method with that name).
alosh alosh

2013/12/26

#
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class bee here. * * @author (your name) * @version (a version number or a date) */ public class bee extends Actor { /** * Act - do whatever the bee wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { if( atWorldEdge()) { turn(17); } move(3); } }
alosh alosh

2013/12/26

#
wht i need from the bee is to turn when it reaches the edge of the world , i tried using this method but didnt work
danpost danpost

2013/12/26

#
Ok. The 'bee' class extends the 'Actor' class. This means that if what you are showing is the entire 'bee' class, then there is no 'atWorldEdge' method declared anywhere. That method can be found in the 'Animal' class that can be imported by way of the menubar ('Edit'>'Import class ...'). You can either copy/paste the method into your 'bee' class or have the 'bee' class extend the 'Animal' class to make the method available for use in that class.
alosh alosh

2013/12/26

#
thanks man :)
You need to login to post a reply.