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

2013/4/29

Error message

infant17 infant17

2013/4/29

#
Anyone what does this error mean and how can it be fixed ERROR incompatible type what does this mean? public void move() { if(wormsEaten) ERROR on this line stating incompatible type { wormEnergy = (wormEnergy + 20); move(4); wormEnergy = (wormEnergy - 1); wormCount = (wormCount - 1); } }
JetLennit JetLennit

2013/4/29

#
what kind of variable is wormsEaten?
infant17 infant17

2013/4/29

#
well I figured out the error but got another error public void countSteps() { numberOfSteps = numberOfSteps + 1; ERROR........cannot find symbol........variable numberOfSteps return numberOfSteps; }
infant17 infant17

2013/4/29

#
Does anyone know what does this error mean and how to fix it public void countSteps() { numberOfSteps = numberOfSteps + 1; ERROR........cannot find symbol........variable numberOfSteps return numberOfSteps; }
JetLennit JetLennit

2013/4/29

#
I am guessing that you never called numberOfSteps
infant17 infant17

2013/4/29

#
well I called it in the public class as a private integer and still got the error and then I called it under the act method and still got the error so I don't know what it means and how to fix it
JetLennit JetLennit

2013/4/29

#
What happens if you change it to a public?
infant17 infant17

2013/4/29

#
it states cannot return a value from method whose result type is void
infant17 infant17

2013/4/29

#
when I take out public void countSteps() { numberOfSteps = numberOfSteps + 1; return numberOfSteps; the program compiles but now when I run the program the crabs don't move they just spin.
danpost danpost

2013/4/29

#
infant17 wrote...
Does anyone know what does this error mean and how to fix it public void countSteps() { numberOfSteps = numberOfSteps + 1; ERROR........cannot find symbol........variable numberOfSteps return numberOfSteps; }
It appears you did not declare the variable 'numberOfSteps' at the top of the class. Also, this method is trying to return an 'int' value ('numberOfSteps'), but is of a 'void' type. You probably should not have this method at all. The incrementing of 'numberOfSteps' should be done along with the code that either 'move's or 'setLocation's the actor.
JetLennit JetLennit

2013/4/29

#
Hadn't noticed that.....
You need to login to post a reply.