2012-09-09 40 views
2
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多維數據集,似乎無法使其工作。我不斷收到錯誤:找不到符號 - 構造函數(java)

cannot find symbol - constructor Square(int,int,int,java.lang.String,boolean) 

有沒有人看到我要去哪裏錯了?請幫忙

回答

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) { 
    } 
}