0
我有一切正確的,但由於某種原因,這給我的問題。我想實現一個名爲populate()的方法。我想在構造函數中調用。我希望它能夠創建每種類型對象的隨機數量的對象。這是我的代碼。 我的錯誤是「* 強大的文本 *構造函數,類淡黃色不能成爲apllied給定類型的淡黃色要求:誠信部發現:不爭論的原因:實際和形式參數列表的長度不同製作一種隨機放置物體在屏幕上的方法。
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);
}
}
}
哪裏是類偏黃。? – 2012-04-23 02:29:30