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

2017/6/22

Question about the crab

HansR HansR

2017/6/22

#
Hi, I'm just beginning with learning greenfoot, and the program doesn't accept my "move" instruction in the crab game (ch. 2). I believe this is because in the Actor Classes I have Actor and then Crab, Animals is not mentioned there as a subclass. Any idea how to solve this?
HansR HansR

2017/6/22

#
I made a subclass Animals, a new subclass Crab, but the error remains. Message is: "method move in class greenfoot.Actor cannot be applied to given types; required: int; found: no argumens; reason: actual and formal argument lists differ in length.
danpost danpost

2017/6/22

#
Please show the actual codes as your description is a bit cryptic in nature. Use code tags to show your Crab class.
HansR HansR

2017/6/22

#
Is it possible to add printscreens? Copie-pasted it gives: public void act() { move(); turn(45); }
Super_Hippo Super_Hippo

2017/6/22

#
You need to add a number into the () after move, so it knows you far you want to move. The Animal class (which you can import) has a move method without parameters which uses a 'speed' value, the Actor doesn't have that. You can add an image of the code if you save a screenshot and upload it. Then you can use the img-tag to post it here. An easier way is to use the code-tags.
HansR HansR

2017/6/22

#
In the book I'm studying from (by Michael Kolling) the example has an Animal class. Any idea whether the version of Greenfoot plays a role?
danpost danpost

2017/6/22

#
HansR wrote...
In the book I'm studying from (by Michael Kolling) the example has an Animal class. Any idea whether the version of Greenfoot plays a role?
No -- the version of greenfoot does not matter. You must have the Crab class extend the Animal class to use the move method without a parameter.
Yehuda Yehuda

2017/6/22

#
HansR wrote...
I made a subclass Animals, a new subclass Crab, but the error remains. Message is: "method move in class greenfoot.Actor cannot be applied to given types; required: int; found: no argumens; reason: actual and formal argument lists differ in length.
...And the animal class should be the one the book is talking about, not one you created yourself leaving it blank.
Super_Hippo Super_Hippo

2017/6/22

#
Click on Edit → Import and choose the Animal class.
You need to login to post a reply.