需求:
键盘录入5个学生信息(姓名,语文成绩,数学成绩,英语成绩),按照总分从高到低存入文本文件
分析:
A:创建学生类
B:创建集合对象
TreeSet
C:键盘录入学生信息存储到集合
D:遍历集合,把数据写到文本文件
首先创建个学生类
package zl_Test;
/**
* 这是个记录学生成绩类
* @author LZL
*
*/
public class Student {
private String name;
private int chinese;
private int math;
private int english;
public Student() {
super();
// TODO Auto-generated constructor stub
}
public Student(String name, int chinese, int math, int english) {
super();
this.name = name;
this.chinese = chinese;
this.math = math;
this.english = english;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getChinese() {
return chinese;
}
public void setChinese(int chinese) {
this.chinese = chinese;
}
public int getMath() {
return math;
}
public void setMath(int math) {
this.math = math;
}
public int getEnglish() {
return english;