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

2013/2/24

counter class

can anyone help me with the counter class. whenever i try the tutorial code, it highlights the word "void" and says "illegal start of expression". can anyone tell me the correct code?
danpost danpost

2013/2/24

#
Please check that your bracketing is correct. If the problem remains, post the class code and specify what error is occuring and where.
here is the code:
void bumpCount(int amount)
{
    totalCount += amount;
    setImage(new GreenfootImage("" + totalCount));
}
the error is it says that the word "void" is an "illegal start of expression" how should i code the counter class?
davmac davmac

2013/2/25

#
Most likely, your bumpCount method is inside another method (and it shouldn't be).
please elaborate
well my cde now can't find the variable "totalCount" what's gong on?
Jonas234 Jonas234

2013/2/26

#
can you post the whole code ?
You need to login to post a reply.