public class Picture
{
private Square s1;
private Square s2;
private Square s3;
private Square s4;
private Square s5;
private Square s6;
private Square s7;
private Square s8;
private Square s9;
/**
* Constructor for objects of class Picture
*/
public Picture()
{
// nothing to do... instance variables are automatically set to null
}
/**
* Draw this picture.
*/
public void draw()
{
s1 = new Square(23,87,104,"red",true);
s2 = new Square(23,112,104,"yellow",true);
s3 = new Square(23,137,104,"magenta",true);
s4 = new Square(23,87,129,"blue",true);
s5 = new Square(23,112,129,"green",true);
s6 = new Square(23,137,129,"yellow",true);
s7 = new Square(23,87,154,"magenta",true);
s8 = new Square(23,112,154,"red",true);
s9 = new Square(23,137,154,"blue",true);
}
}
我不得不为类创建一个rubix多维数据集,似乎无法使其工作。我一直收到错误:
cannot find symbol - constructor Square(int,int,int,java.lang.String,boolean)
有谁看到我错在哪里?请帮忙
答案 0 :(得分:3)
您尚未包含Square
的来源,但我可以告诉您,它没有包含这些参数的公共构造函数。这些行引起了问题:
s1 = new Square(23,87,104,"red",true); // etc
你的Square
类需要有这样的构造函数:
public class Square {
public Square(int a, int b, int c, String color, boolean flag) {
}
}