求一个java编程题的答案

编写满足以下要求的类:
①Student类:含id(学号)、name(姓名)、isMale(是否为男性)、birth(生日)等私有字段
(注意合理设置各字段的类型)。
②使用Eclipse自动产生Student类各字段的getter/setter方法。
③使用Eclipse自动产生Student类的默认及完全构造方法。
④使用Eclipse自动产生Student类重写Object根类的toString方法的代码框架,并返
回由各字段信息组成的字符串。
⑤StudentTest类:在其main方法中编写合适代码测试Student类

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
class Student {

private String id;

private String name;

private boolean isMale;

private Date birth;
public Student() {
super();
}
public Student(String id, String name, boolean isMale, Date birth) {
super();
this.id = id;
this.name = name;
this.isMale = isMale;
this.birth = birth;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isMale() {
return isMale;
}
public void setMale(boolean isMale) {
this.isMale = isMale;
}
public Date getBirth() {
return birth;
}
public void setBirth(Date birth) {
this.birth = birth;
}
@Override
public String toString() {
return "Student [id=" + id + ", name=" + name + ", isMale=" + isMale + ", birth=" + birth + "]";
}
}
public class StudentTest {

public static void main(String[] args) throws ParseException {

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");

Student stu = new Student("00001", "Tom", true, dateFormat.parse("2000-01-01"));
System.out.println(stu);
}
}
温馨提示:答案为网友推荐,仅供参考