学生信息管理系统源代码
import java.io.*;
class StuInfo {
public String name;
public int number;
public String sex;
public String age;
public String bir;
public String email;
public String addr;
public String tel;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getBir() {
return bir;
}
public void setBir(String bir) {
this.bir = bir;
}
public String getEmail() {
return email;
}
public void setEmail(String email ) {
this.email = email;
}
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
this.addr = addr;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
}
public class Student {
private static PrintStream out = System.out;
private static String filename = \"Stu.txt\";
private static int total = 0;
private static int rt = 0;//recyle length
private StuInfo[] stuInfos;
private StuInfo[] recycle;
BufferedReader buf = new InputStreamReader(System.in));//创建缓冲流
public Student(){
stuInfos = new StuInfo[11];
}
public void 信息录入(){
BufferedReader buf = new InputStreamReader(System.in));
try{
System.out.print(\"\\n请输入学生信息(以0结束)\\n\");
System.out.print(\"学号:\\n\");
StuInfo stu = new StuInfo();
BufferedReader(new
BufferedReader(new
stu.setNumber(Integer.parseInt(buf.readLine()));
while(stu.getNumber()!=0) {
System.out.print(\"姓名:\\n\\n\");
stu.setName(buf.readLine());
System.out.print(\"性别:\\n\\n\");
stu.setSex(buf.readLine());
System.out.print(\"年龄:\\n\\n\");
stu.setAge (buf.readLine());
System.out.print(\"生日:\\n\\n\");
stu.setBir(buf.readLine());
System.out.print(\"邮箱:\\n\\n\");
stu.setEmail(buf.readLine());
System.out.print(\"地址:\\n\\n\");
stu.setAddr(buf.readLine());
System.out.print(\"电话:\\n\\n\");
stu.setTel(buf.readLine());
//添加其他输入信息
stuInfos[total]=stu;
total++;
stu = new StuInfo();
System.out.print(\"\\n请输入下一个学生信息(以0结束)\\n\");
System.out.print(\"姓名:\\n\");
stu.setName(buf.readLine());
}
}catch(Exception e){
out.print(e);
}
}
public void 保存数据(){
try{
FileWriter fwr=new FileWriter(filename);
BufferedWriter fw = new BufferedWriter(fwr);
fw.write(total+\"\\r\\n\");
for(int k=0;kfw.write(stuInfos[k].getNumber()+\"\\r\\n\");fw.write(stuInfos[k].getName()+\"\\r\\n\");
fw.write(stuInfos[k].getSex()+\"\\r\\n\");
fw.write(stuInfos[k].getAge()+\"\\r\\n\");
fw.write(stuInfos[k].getBir()+\"\\r\\n\");
fw.write(stuInfos[k].getEmail()+\"\\r\\n\");
fw.write(stuInfos[k].getAddr()+\"\\r\\n\");
fw.write(stuInfos[k].getTel()+\"\\r\\n\");
}
fw.write(rt+\"\\r\\n\");
for(int k=0;k