题目:定义一个表示学生的类Student。这个类的属性有“学号”、“班号”、“姓名”、“性别”、“年龄”,方法有“获得学号”、“获得班号”、“获得性别”、“获得姓名”、“获得年龄”。
public class Student{
private int xh,code,age;
private String name,sex;
public Student(int xh,int code,String name,String sex,int age){
super();
this.xh=xh;
this.code=code;
this.name=name;
this.sex=sex;
this.age=age;
}
public int GetXh(){
return xh;
}
public int GetCode(){
return code;
}
public String GetName(){
return name;
}
public String GetSex(){
return sex;}
public int age(){
return age;}
public void show(){
System.out.println("学号: "+"班号: "+"姓名: "+"性别 : "+"年龄: ");
}
public static void main(String args[]){
Student s=new Student(1818,1,"lina","女",19);
s.xh=1818;
s.code=1;
s.name="lina";
s.sex="女";
s.age=19;
}
}