2014-10-02 107 views
0

我在主程序中出現錯誤,任何人都可以幫我找到錯誤在哪裏?我試圖創建一個類,使用的setter /吸氣設定每個字段,其中最終我會測試這個類它,以確保下地幹活找不到錯誤

public class College{ 

    public class person{ 

     private String name; 
     private int age; 
     private double id; 
     //constructor to set fields 
     public Schedule (String name, int age, double id){ 
      this.name= name; 
      this.age= age; 
      this.id= id; 
     } 

     public String getName(){ 
      return this.name; 
     } 

     public void setName(String Name) { 
      this.name= name; 
     } 
     public int getAge(){ 
      return this.Age; 
     } 

     public void setAge(int age) { 
      this.age = age; 
     } 
     public double getId(){ 
      return this.id; 
     } 

     public void setId(double id) { 
      this.id = id; 
     } 


    } 

    public static void main(String[] args) { 


     Schedule Per1= new College("John", 2,2.0); 



    } 


} 
+0

你需要顯示從主代碼,你嘗試實例/操縱類。 – Tim 2014-10-02 02:38:10

回答

0

我想你可能想了解如何創建類正常。 下面的鏈接會幫助你(在C#):

http://msdn.microsoft.com/en-us/library/x9afc042.aspx

public class person{ 

    private String name; 
    private int age; 
    private double id; 
    //constructor to set fields 
    public person(String name, int age, double id){ 
     this.name= name; 
     this.age= age; 
     this.id= id; 
    } 

    public String getName(){ 
     return this.name; 
    } 

    public void setName(String Name) { 
     this.name= name; 
    } 
    public int getAge(){ 
     return this.Age; 
    } 

    public void setAge(int age) { 
     this.age = age; 
    } 
    public double getId(){ 
     return this.id; 
    } 

    public void setId(double id) { 
     this.id = id; 
    } 


} 

public static void main(String[] args) { 


    person Per1= new person("John", 2,2.0); 



} 
+0

明白了謝謝! – 2014-10-02 03:18:06