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

2019/6/22

making a method add

Coltz Coltz

2019/6/22

#
public void act()
    {
        YouWin();
    }
    
    
    public void YouWin()
    {
        int numberOfApple = getObjects(Apple.class).size();
        int numberOfPizza = getObjects(Pizza.class).size();
        int numberOfFruit = numberOfApple() + numberOfPizza();
        if (numberOfFruit == 0)
        {
            addObject(new YouWin(), getWidth()/2, getHeight()/2);
            Greenfoot.stop();
        }
    }
Super_Hippo Super_Hippo

2019/6/22

#
Do you have a question? You need to remove the () () in line 11.
Coltz Coltz

2019/6/22

#
thank you
You need to login to post a reply.