[java]代码库
public class Student01 {
private final int id = 1;
private int age;
private String name;
private int classes;
private static String school ="合师";
public Student01(){
this(22,"小明",424);
}
public Student01(int age,String name,int classes){
this.age = age;
this.name = name;
this.classes = classes;
}
public void setAge(int age){ //修改年龄
this.age = age;
}
public void setName(String name){ //修改姓名
this.name = name;
}
public void setClasses(int classes){ //修改班级
this.classes = classes;
}
public int getId(){ //获取学号
return id;
}
public int getAge(){ //获取年龄
return age;
}
public String getName(){ //获取姓名
return name;
}
public int getClasses(){ //获取班级
return classes;
}
public String getSchool(){ //获取学校
return school;
}
public String getInFo(){
return "学号:" + id + ";\t\t年龄:" + age + ":\t\t姓名:" + name +
":\t\t班级:" + classes + ":\t\t学校:" + school;
}
public static void main(String[] args) {
Student01 student01 = new Student01();
System.out.println(student01.getInFo());
Student01 student02 = new Student01();
student02.setAge(20);
student02.setName("小亮");
student02.setClasses(555);
System.out.println("学号:" + student02.getId() + ":\t\t年龄:" + student02.getAge()
+":\t\t姓名:" + student02.getName() + ":\t\t班级:" + student02.getClasses( )
+ ":\t\t学校:" + student02.getSchool());
}
}
by: 发表于:2017-07-14 10:12:22 顶(0) | 踩(0) 回复
??
回复评论