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

2014/12/14

Help with an error? (Illegal start of expression)

Bluephoenix14 Bluephoenix14

2014/12/14

#
Long story short, I was working on an actor's code, and somehow I must've highlighted a different section because when I typed everything started being typed over and got really screwed up. I'm trying to fix everything (I already tried undoing the mistakes but it won't take it back) and have been retyping all my methods. I finally finished about 3/4ths of the coding for this actor and when I hit compile, it keeps saying that I have an illegal start of expression in a line of code (I'll provide it at the bottom). Could anyone help me figure this out? I've been trying to retype it again, and look for curly brackets, but I can't fix it. To clarify, it's giving me the error at the "public boolean canSee... Here's the method code that I have: public void checkKeyPress() { if(Greenfoot.isKeyDown("left")) { turn(-4); } if(Greenfoot.isKeyDown("right")) { turn(4); } public boolean canSee(Class clss) { Actor actor = getOneObjectAtOffset(0, 0, clss); return actor != null; } { World world; world = getWorld(); world.removeObject(bacteria); }
hhoogerwerf hhoogerwerf

2014/12/14

#
I am no expert, but just want to give you a thing you can try. Define the boolean in another part of the code, not in the methode. You can still change it, but don't make it there.
Super_Hippo Super_Hippo

2014/12/14

#
You don't end the 'checkKeyPress' method before starting the 'canSee' method. Add a } there. The last 5 lines won't work like that either. They should be inside the right method.
hhoogerwerf wrote...
Define the boolean in another part of the code, not in the methode. You can still change it, but don't make it there.
Which boolean?
hhoogerwerf hhoogerwerf

2014/12/14

#
nevermind I didn't see he wanted to start a new method. I thought he wanted to make a boolean my bad.
You need to login to post a reply.