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

2013/1/6

incompatible types with range

KierTulp KierTulp

2013/1/6

#
hey! I keep getting incompatible types with my code, I think it is because I am using a boolean. Does anyone know a way of fixing this?
public boolean isUmanNear()
    {
         if(getObjectsInRange(40, Uman.class))
         {
         return true;
        }
         else 
         {
             return false;
         }
          
    }
Thanks!
erdelf erdelf

2013/1/6

#
getObjectsInRange is returning a list, if needs to check something
Gevater_Tod4711 Gevater_Tod4711

2013/1/6

#
If you want to prove if there is an object type uman near you, you should change the method like this:
public boolean isUmanNear()  {
    if(!getObjectsInRange(40, Uman.class).isEmpty()) {
       return true;
    }
    else {
        return false;
    }
}  
You need to login to post a reply.