Hi all, we just have started Greenfoot Java programming in school and I have a question regarding the getObjectsInRange Method: When a crab notices a Lobster in its range I want the crab to move away from the Lobster, so I created a class called Instinct where I have methods about animals behaviors. On of them is avoid:
In the Crab class I use the avoid Method and call it like this:
avoid(Lobster.class);
But when the Crab moves to the Lobster it doesn't turn. Why?
Would be nice, if anyone can help me out ;)
Best, Postamt
public void avoid(java.lang.Class clss) { java.util.List actors = getObjectsInRange(50,clss); if (actors.contains(clss)) { turn(45); } }