学生信息管理系统源代码.docx
《学生信息管理系统源代码.docx》由会员分享,可在线阅读,更多相关《学生信息管理系统源代码.docx(16页珍藏版)》请在冰豆网上搜索。
学生信息管理系统源代码
学生信息管理系统源代码
importjava.io.*;
classStuInfo{
publicStringname;
publicintnumber;
publicStringsex;
publicStringage;
publicStringbir;
publicStringemail;
publicStringaddr;
publicStringtel;
publicStringgetName(){
returnname;
}
publicvoidsetName(Stringname){
this.name=name;
}
publicintgetNumber(){
returnnumber;
}
publicvoidsetNumber(intnumber){
this.number=number;
}
publicStringgetSex(){
returnsex;
}
publicvoidsetSex(Stringsex){
this.sex=sex;
}
publicStringgetAge(){
returnage;
}
publicvoidsetAge(Stringage){
this.age=age;
}
publicStringgetBir(){
returnbir;
}
publicvoidsetBir(Stringbir){
this.bir=bir;
}
publicStringgetEmail(){
returnemail;
}
publicvoidsetEmail(Stringemail){
this.email=email;
}
publicStringgetAddr(){
returnaddr;
}
publicvoidsetAddr(Stringaddr){
this.addr=addr;
}
publicStringgetTel(){
returntel;
}
publicvoidsetTel(Stringtel){
this.tel=tel;
}
}
publicclassStudent{
privatestaticPrintStreamout=System.out;
privatestaticStringfilename="Stu.txt";
privatestaticinttotal=0;
privatestaticintrt=0;//recylelength
privateStuInfo[]stuInfos;
privateStuInfo[]recycle;
BufferedReaderbuf=newBufferedReader(newInputStreamReader(System.in));//创建缓冲流
publicStudent(){
stuInfos=newStuInfo[11];
}
publicvoid信息录入(){
BufferedReaderbuf=newBufferedReader(newInputStreamReader(System.in));
try{
System.out.print("\n请输入学生信息(以0结束)\n");
System.out.print("学号:
\n");
StuInfostu=newStuInfo();
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=newStuInfo();
System.out.print("\n请输入下一个学生信息(以0结束)\n");
System.out.print("姓名:
\n");
stu.setName(buf.readLine());
}
}catch(Exceptione){
out.print(e);
}
}
publicvoid保存数据(){
try{
FileWriterfwr=newFileWriter(filename);
BufferedWriterfw=newBufferedWriter(fwr);
fw.write(total+"\r\n");
for(intk=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(intk=0;k