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

2016/11/22

Need help with code for World

Lars2501 Lars2501

2016/11/22

#
Can someone help me with my problem. I can't find the solution for my code. Already thank you very much for helping me. I'm sorry for my horrible English.
 public void act()
    {
        if(getObjects(Complete.class).size() = 1 && !ready())
        {
         Greenfoot.delay(200);
         Greenfoot.setWorld(new Instructiescherm2());
        }
    }
    public boolean ready()
    {
        getObjects(Complete2.class).size() = 2;
    }
't find the solution to finish my code. It is a World-code
danpost danpost

2016/11/22

#
A single equal sign, '=', is an assignment operator; and you cannot assign a value to a method call. The operator you need to use is the conditional equality operator, which is a double equal sign, '=='. Also, the 'ready' method, which returns a boolean value (or any method that return anything) must have a 'return' statement. I believe the method should read:
public boolean ready()
{
    return getObjects(Complete2.class).size() == 2;
}
You need to login to post a reply.