2014-10-02 103 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