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

2014/9/29

Creating multiple condition if-then statements.

Dahoneybadger11 Dahoneybadger11

2014/9/29

#
Ok, so i'm trying to make a if than statement that required two actions two happen in order to allow the secondary method to happen. I was wondering if anyone could help me out and tell me what im doing wrong.
1
2
3
4
if (canSee(Anthill.class) && F = 1)
{
  setImage("ant.png");
}
The error message reads
bad operand types for binary operator '&&' first type: boolean; second type: int;
Thanks in advance for any advice!
danpost danpost

2014/9/29

#
The part 'F = 1' does not produce a true/false (boolean) value. It only sets 'F' to the value of '1'. For comparing two values for equality, you must use the '==' operator ( 'F == 1' ).
You need to login to post a reply.