急啊~~周二要一个STUDENT的类;

来源:百度知道 编辑:UC知道 时间:2024/06/20 09:07:43
类要包含域:学号,班号,姓名,性别,年龄
类的方法:获得学号,获得班号,获得姓名,获得性别,修改年龄。

楼上获取年龄和性别那里最好改成getName()和getSex().
作为一个POJO的书写规范。

public class Student{
public int id;
public int classId;
public String name;
public String sex;
public int age;
public int getId(){
return this.id;;
}
public int getClassId(){
return this.classId;
}
public String getName(){
return this.name;
}
public String setSex(){
return this.sex;
}
public int getAge(){
return this.age;
}
public void setAge(int age){
this.age=age;
}
}
就这样的说白点,你要写的就是一个pojo(古老的java类只有getter和setter方法)

不知这样会不会是帮倒忙呢,其实这些东西你是学习的话,最好自己慢慢写!
public class Student{
public Student(){
}
private String stuNo;
private String stuClass;
private String stuName;
private String stuSex;
private int stuAge;

public String getStuNo(){
return stuNo;
}

public String getStuClass(){
return stuClass;
}