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

2011/11/20

Cannot return a value from method whose result type is void

darkmist255 darkmist255

2011/11/20

#
I changed it to double and it no longer has an error, disregard this :D. I'm working on adding a few things to the asteroid game I made a while back. What I'm doing is keeping track of the score in the actor that the player controls. My goal is the following: Working: When the ball hits the asteroid, it does castle.addDestroyed(); which adds 1 to the value
public void addDestroyed()
    {
        destroyedCount = (destroyedCount + 1);
    }
Not working: When the asteroid spawns, it determines its speed based on the square root of castle.getDestroyedCount(); which looks like this:
public void getDestroyedCount()
    {
        return destroyedCount;
    }
When I try to compile it says "cannot return a value from method whose result type is void" Is that because this is a public void? What other types are there? Should I set it to double, since that's what destroyedCount is? Anyway, is this the most efficient way to do it? Keep score somewhere persistent, access it when needed?
darkmist255 darkmist255

2011/11/20

#
I changed it to double and it no longer has an error, disregard this :D.
You need to login to post a reply.