package test;
public class student1 {
Private String id;
Private String name;
Private int age;
public student1() {
}
public student1(String id, String name){
this.id = id;
this.name = name;
}
public student1(String id, String name, int age) {
//this(id,name);
//this.age = age;
this(id,name);
this.age = age;
}
public void setAge(int a) {
if(a<18) a = 18;
age = a;
}
public int getAge() {
return age;
}
void walk() {
System.out.println("walking...");
}
}
package test;
public class test1 {
public static void main(String[]args ) {
// TODO 自动生成的方法存根
student1 s = new student1("09190501","Tom",19);
//s.id = "09190501";
//s.name = "Tom";
//s.age = -18;
//s.setage(10);
//System.out.println(s.id);
System.out.println(s.getAge());
s.walk();
student1 s1 = new student1();
//s.id = "09190502";
//s.name = "Lily";
//System.out.println(s1.id);
System.out.println(s1.getAge());
}
}