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

2019/6/1

Could you help me I get error in this part         

elizabethlc elizabethlc

2019/6/1

#
List<Object> rocas=getObjectsInRange(200,roca.class);
        
        Iterator it=rocas.iterator();
        if(it.hasNext())
        {
            roca r=(roca)it.next();
            if(r!=null)
            {
                turnTowards(r.getX(),r.getY());
            }
        }
error (200,roca,class);
danpost danpost

2019/6/1

#
What is the error message?
elizabethlc elizabethlc

2019/6/1

#
danpost wrote...
What is the error message?
Incompatible tyes: inferred type does not conform to equality constraint(s) please help me
danpost danpost

2019/6/1

#
elizabethlc wrote...
danpost wrote...
What is the error message?
Incompatible tyes: inferred type does not conform to equality constraint(s) please help me
Change <Object> in line 1 to <Actor>.
elizabethlc elizabethlc

2019/6/1

#
danpost wrote...
elizabethlc wrote...
danpost wrote...
What is the error message?
Incompatible tyes: inferred type does not conform to equality constraint(s) please help me
Change <Object> in line 1 to <Actor>.
Thank you very much or your help, I already did or did and the same error keeps coming up.
Super_Hippo Super_Hippo

2019/6/1

#
Change it to "roca".
danpost danpost

2019/6/1

#
Maybe you can avoid the error by coding it as follows:
for (Object obj : getObjectsInRange(200, roca.class))
{
    Actor r = (Actor)obj;
    turnTowards(r.getX(), r.getY());
    break;
}
elizabethlc elizabethlc

2019/6/2

#
Super_hippo wrote...
Change it to "roca".
Thank you very much, it worked for me.
You need to login to post a reply.