当我编译此错误出现时,我不确定可能出现的错误。
这是编译时出现的错误:
Error: no suitable constructor found for Turtle(no arguments)
constructor Turtle.Turtle(int,int,Picture) is not applicable
(actual and formal argument lists differ in length)
constructor Turtle.Turtle(int,int,ModelDisplay) is not applicable
(actual and formal argument lists differ in length)
constructor Turtle.Turtle(ModelDisplay) is not applicable
(actual and formal argument lists differ in length)
constructor Turtle.Turtle(Picture) is not applicable
(actual and formal argument lists differ in length)
这是我写的代码:
public class CreateShapes extends Turtle
{
{
//Put all your commands to call drawShape 4 times on 4 different turtle objects
World world1 = new World();
Turtle turtle1 = new Turtle(50,50,world1);
turtle1.drawShape(100);
Turtle turtle2 = new Turtle(100, 100,world1);
turtle1.drawShape(200);
Turtle turtle3 = new Turtle(200,200,world1);
turtle1.drawShape(300);
Turtle turtle4 = new Turtle(300,300, world1);
turtle1.drawShape(400);
}
}
答案 0 :(得分:0)
似乎Turtle
有四个不同的构造函数:一个有两个int
s和一个Picture
个实例,一个有两个int
s和一个ModelDisplay
实例,一个带有ModelDisplay
实例的实例,另一个带有Picture
实例的实例作为参数传递。
您正尝试使用两个Turtle
和一个int
实例启动World
。
除非World
是ModelDisplay
或Picture
的子类,否则无效。确保提供正确的第三个参数。