I am puzzled as to why my subclass turtle does not inherit the three methods (atWorldEdge(), canSee(), and eat()) from the Animal class.
Please help, I am just stuck here!
I am new on Greenfoot online video tutorials which I am trying to follow as quick as I can.
Yes (Java rule on class naming, of course)! In fact it is all now sorted, by just copying the Animal class version 1.0 of Dr Michael Kolling and pasting it into the empty Act method of the Animal class version I got on my system. I've found it on one of his scenarios.
I wish such file would have been posted on the Support Classes web page for all to download.
Thanks anyway
I wish such file would have been posted on the Support Classes web page for all to download.
Thanks anyway
The greenfoot Actor class has had 'isTouching' and 'removeTouching' methods included in them in versions 2.3 and 2.4. Also, in 2.4, included was an 'isAtEdge' method. So. the Animal class is kind of obsolete ('isTouching' is 'canSee', 'removeTouching' is 'eat' and 'isAtEdge' is 'atWorldEdge').
In fact it is all now sorted, by just copying the Animal class version 1.0 of Dr Michael Kolling and pasting it into the empty Act method of the Animal class
This doesn't sound like the right way to use the Animal class. You should have your Turtle class extend Animal (so Turtle is a subclass of Animal, instead of Actor directly). You should not need to modify the Animal class itself.
Thank you danpost for letting me know about Greenfoot 2.4 and its additional methods, which version I have now installed. As davmac does rightly remind me, indeed my Turtle inherits from Animal, which inherits from Actor, but these two classes do come with empty Act methods, which startled me somewhat. So I proceeded as instructed in the video tutorials, namely, empty the contents on the Animal class first, then paste the Animal class version 1.0 by Michael Kolling, and it worked.
I guess I should try invoke isTouching, removeTouching, and isAtEdge methods in the Turtle class, which inherits directly from Actor, right?