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

2012/3/1

classes and methods

Alfie5 Alfie5

2012/3/1

#
i keep getting the error messages that class is not recognized or hidden and some methods are not recognized such as eat and canSee for example the below code does not work even though there is a class called Notes * @version (a version number or a date) */ public class player1 extends Mover { /** * Act - do whatever the player1 wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { // player follow the mouse if(Greenfoot.mouseMoved(null)) { MouseInfo mouse = Greenfoot.getMouseInfo(); setLocation(mouse.getX(), mouse.getY()); } //see note eat it if( canSee(Notes.class) ) { eat(Notes.class); } } }
darkmist255 darkmist255

2012/3/2

#
Have you written a class called canSee() and eat()? If so, they need to be able to accept some input (the Notes.class) so that you can tell it what to eat. I can go into more detail if you would like, but sorry I'm just popping on Greenfoot for a minute :D.
Alfie5 Alfie5

2012/3/2

#
I thought CanSee and eat where Greenfoot methods already built in that is what the book implies. What do I do? I just want my man to eat the object it comes across.
dlanni dlanni

2012/3/2

#
CanSee and other methods are in the Animal class. If you have the crab scenario, just r click on Animal (subclass of Actor), open editor and copy and paste any methods you want. For an explanation of why the author set it up this way (and some really great video tutorials), visit the author's blog(Mik at Kent Univ) In about the 4th video, he explains that dumping so much code writing on beginnig students would not be good.
darkmist255 darkmist255

2012/3/2

#
Hmm... I must've missed something when I did my crab scenario (very likely), because I don't have an animal class anywhere :(. Sorry, but I would need to see what the animal class is to see why it doesn't like your code. Do you know if there's a download somewhere on the site to a completed crab scenario (I looked for a bit, but had no luck). If not, do you think you could post the animal class methods on this discussion?
You need to login to post a reply.