0

I have everything else correct, but for some reason this is giving me problems. I want to implement a method called populate(). i want to be called in the constructor. I want it to the method to create a random number of objects of each type of object. This is my code. my error is "*strong text*constructor yellowish in class yellowish cannot be a apllied to given types. required: int found: not argument reason: actual and form argument list differ in length.

public class FishWorld extends World
{

    /**
     * Constructor for objects of class FishWorld.
     * 
     */
    public FishWorld() 
    {

        super(600, 400, 1);

        populate();
        populate2();
        populate3();
    }


    public void populate()
    {
        int randX;
        int randY;

        for(int i = 0; i < 5; i++)
        {
            YellowFish yf = new YellowFish();
            randX = Greenfoot.getRandomNumber ( getWidth() );
            randY = Greenfoot.getRandomNumber( getHeight() );
            addObject(yf, randX, randY);
        }
    }
    public void populate2()
    {
        int randX;
        int randY;
        for(int i = 0; i < 5; i++)
        {
            GreenFish gf = new GreenFish();
            randX = Greenfoot.getRandomNumber ( getWidth() );
            randY = Greenfoot.getRandomNumber( getHeight() );
            addObject(yf, randX, randY);
        }
    }
    public void populate3()
    {
        int randX;
        int randY;
        for(int i = 0; i < 5; i++)
        {
            StripeFish sf = new StripeFish();
            randX = Greenfoot.getRandomNumber ( getWidth() );
            randY = Greenfoot.getRandomNumber( getHeight() );
            addObject(yf, randX, randY);
        }
    }
}
Tejas Patil
  • 6,149
  • 1
  • 23
  • 38
New2.java
  • 29
  • 6

1 Answers1

1

It seems you don't have empty parameter constructor in class YellowFish. You might want to add:

public YellowFish() {
// ... your code here
}

in the YellowFish class.

JScoobyCed
  • 10,203
  • 6
  • 34
  • 58