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

2013/4/8

cannot find symbol help.

gonnaownurass gonnaownurass

2013/4/8

#
I am doing the turtle thing and im trying to add a snake to eat the turtle. but when i set it to eat the turtle when it can it says cannot find symbol. My code is import greenfoot.*; public class Snake extends Actor { public void act() {move(3); if(Greenfoot.getRandomNumber(100)<10) { turn((Greenfoot.getRandomNumber(40)-20)); } if(canSee(Turtle.class)) { eat(Turtle.class); } if(atWorldEdge()) { turn(13); } } } any help would be appreciated.
Gevater_Tod4711 Gevater_Tod4711

2013/4/8

#
Probably you havend declared one (or more) of the methods you are using. Does it say which symbol exactly it isn't able to find? Or in which line the error occours?
danpost danpost

2013/4/8

#
More specifically, the only things it would have a problem finding are (1) 'canSee', (2) 'eat', and (3) 'atWorldEdge', which are all methods in the Animal class. Since your Snake class extends Actor and not Animal the compiler cannot find those methods. As an alternative to sub-classing the Animal class, you can copy those methods from the Animal class into the Snake class.
gonnaownurass gonnaownurass

2013/4/9

#
thanks i just turned actor to animal and now its working fine.Thanks
You need to login to post a reply.