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

2014/12/10

Help with an error regarding a symbol?

Bluephoenix14 Bluephoenix14

2014/12/10

#
I'm trying to create a game for school that's somewhat like the "Crab Game" on here, so I was trying to enter in some code from the game (I made comments explaining where I got the pre-made code from) into one of my own actor classes. Anyways, there's a section of code regarding the method (my game is based on pathogens and white blood cells): public void lookForPathogen() { if(canSee(Pathogen.class)) { eat(Pathogen.class); pathogensEaten = pathogensEaten +1; if(pathogensEaten == 8) {Greenfoot.stop(); } } } That's the whole method. Anyways, when I try to compile it, I get an error saying: "cannot find symbol - method canSee(java.land.Class<Pathogen>)" . From what I've learned in class, I know that it's indicating that I haven't defined the method basically, but when I look through the whole "Crab Game" I can't find any place where if(canSee(Worm.class)) is defined properly. How can I fix this error? I know it's a lot, but thanks for anyone's help!
danpost danpost

2014/12/10

#
The greenfoot.Actor class does not contain any method called 'canSee' or 'eat'. The class you got the code from probably extended the Animal class (which contains those methods). You might want to review what methods ARE available in the greenfoot.Actor class to see if there are any suitable replacements
Bluephoenix14 Bluephoenix14

2014/12/11

#
I will do that. Thank you for your help!
You need to login to post a reply.