java学生成绩管理系统课程设计报告.docx

上传人:b****4 文档编号:5005786 上传时间:2022-12-12 格式:DOCX 页数:35 大小:141.78KB
下载 相关 举报
java学生成绩管理系统课程设计报告.docx_第1页
第1页 / 共35页
java学生成绩管理系统课程设计报告.docx_第2页
第2页 / 共35页
java学生成绩管理系统课程设计报告.docx_第3页
第3页 / 共35页
java学生成绩管理系统课程设计报告.docx_第4页
第4页 / 共35页
java学生成绩管理系统课程设计报告.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

java学生成绩管理系统课程设计报告.docx

《java学生成绩管理系统课程设计报告.docx》由会员分享,可在线阅读,更多相关《java学生成绩管理系统课程设计报告.docx(35页珍藏版)》请在冰豆网上搜索。

java学生成绩管理系统课程设计报告.docx

java学生成绩管理系统课程设计报告

简单学生成绩管理系统的设计与实现

1设计目的及内容要求

1、设计目的:

巩固和加深学生对高级语言程序设计课程的基本知识的理解和掌握,掌握java语言编程和程序调试的基本技能,利用java语言进行基本的软件设计,提高运用java语言解决实际问题的能力。

2、内容要求

实现学生成绩的管理(增、删、改、查询、持久化、成绩排序、成绩统计等功能),在文件中增加、删除、学生信息,根据学号查询、修改学生信息,统计功能求每个人的总分并按从高到低排序,通过这些操作对文件中的信息保存。

2系统总体设计

成功登陆系统以后,出现成绩管理界面,系统初始化,可对学生成绩进行增加、删除、查询、修改、统计,进入相应界面进行成绩管理,退出系统自动保存本次操作内容,保存信息。

简易流程图:

3系统详细设计

创建Student类,设置变量及对应方法

Student.java代码:

packagekeshe;

importjava.io.Serializable;

publicclassStudentimplementsSerializable{

privateStringname;

privateintnum;

privateintyuwen;

privateintshuxue;

privateintjava;

privateintsum=0;

publicStudent(){

}

publicStudent(Stringname,intnum,intyuwen,intshuxue,

intjava){

super();

this.name=name;

this.num=num;

this.yuwen=yuwen;

this.shuxue=shuxue;

this.java=java;

}

publicStringgetName(){

returnname;

}

publicvoidsetName(Stringname){

this.name=name;

}

publicintgetNum(){

returnnum;

}

publicvoidsetNum(intnum){

this.num=num;

}

publicintgetYuwen(){

returnyuwen;

}

publicvoidsetYuwen(intyuwen){

this.yuwen=yuwen;

}

publicintgetShuxue(){

returnshuxue;

}

publicvoidsetShuxue(intshuxue){

this.shuxue=shuxue;

}

publicintgetJava(){

returnjava;

}

publicvoidsetJava(intjava){

this.java=java;

}

publicintgetSum(){

returnsum;

}

publicvoidsetSum(intsum){

this.sum=sum;

}

publicStringtoString(){

return"Student[name="+name+",num="+num+",yuwen="+yuwen

+",shuxue="+shuxue+",java="+java+",sum="+sum

+"]";

}

}

Student管理类StuC,创建对应方法,实现对Student对象的操作(增、删、改、查询、持久化、成绩排序、成绩统计等功能)供其对象调用。

StuC.java代码

packagekeshe;

importjava.io.BufferedReader;

importjava.io.File;

importjava.io.FileInputStream;

importjava.io.FileNotFoundException;

importjava.io.FileOutputStream;

importjava.io.FileReader;

importjava.io.IOException;

importjava.io.ObjectInputStream;

importjava.io.ObjectOutputStream;

importjava.util.ArrayList;

publicclassStuC{

ArrayListal=newArrayList();

Filefile=newFile("e:

/mydata.dat");

//添加

publicvoidadds(Students){

al.add(s);

}

//删除

publicvoiddel(intn){

for(inti=0;i

if(al.get(i).getNum()==n)

al.remove(i);

}

}

//求总分

publicvoidsum(){

for(inti=0;i

al.get(i).setSum(al.get(i).getJava()+al.get(i).getShuxue()+al.get(i).getYuwen());

}

}

//排序

publicvoidsort(){

for(inti=0;i

for(intj=0;j

if(al.get(j).getSum()

Objecto=al.get(j);

al.set(j,al.get(j+1));

al.set(j+1,(Student)o);

}

}

}

}

publicvoidpaint(){

for(inti=0;i

System.out.println(al.get(i));

}

}

publicStringtoString(){

return"StuC[al="+al+"]";

}

//输出流

publicvoidstor()

{

ObjectOutputStreamout=null;

try{

out=newObjectOutputStream(newFileOutputStream(file));

out.writeObject(al);

out.close();

}catch(FileNotFoundExceptione){

e.printStackTrace();

}catch(IOExceptione){

e.printStackTrace();

}

}

//输入流

publicvoidread()

{

ObjectInputStreamin=null;

try{

in=newObjectInputStream(newFileInputStream(file));

try{

al=(ArrayList)in.readObject();

}catch(ClassNotFoundExceptione){

al=null;

}

in.close();

}catch(FileNotFoundExceptione){

Filefile=newFile("e:

/mydata.dat");

}catch(IOExceptione){

e.printStackTrace();

}

}

//查找

publicStudentfind(intn)

{

for(inti=0;i

if(al.get(i).getNum()==n){

returnal.get(i);

}

}

returnnull;

}

}

登陆界面及成绩管理的所有界面,同过创建StuC的对象,调用其方法实现成绩管理

代码:

packagekeshe;

importjava.awt.*;

importjava.awt.event.*;

importjava.io.FileNotFoundException;

importjava.io.IOException;

importjavax.swing.*;

publicclassLoginextendsJFrame{

privateTextFieldf1;

privateTextFieldf2;

privateJButtonb1;

privateJButtonb2;

privateJButtonb3;

StuCscs=newStuC();

//登陆界面

publicLogin(){

Containercp=getContentPane();//容器

cp.setLayout(newGridLayout(3,1));//三行一列布局

Labell1=newLabel("用户名");

Labell2=newLabel("密码");

Panelp1=newPanel();

Panelp2=newPanel();

Panelp3=newPanel();

f1=newTextField(10);

f2=newTextField(10);

f2.setEchoChar('*');//回显字符为*

b1=newJButton("登录");

b2=newJButton("重置");

b3=newJButton("退出");

p1.add(l1);//第一行添加label1

p1.add(f1);

p2.add(l2);

p2.add(f2);

p3.add(b1);

p3.add(b2);

p3.add(b3);

cp.add(p1);

cp.add(p2);

cp.add(p3);

b1.addActionListener(newEnter());

b2.addActionListener(newReWrite());

b3.addActionListener(newClose());

}

classEnterimplementsActionListener{

publicvoidactionPerformed(ActionEvente)

{

if((f1.getText()).equals("yazhou")&&(f2.getText()).equals("123456"))

{

scs.read();//初始化,从文件读入信息

XueShengframe1=newXueSheng();

frame1.setBounds(200,200,300,300);

frame1.setVisible(true);

}

elseJOptionPane.showMessageDialog(null,"用户名或密码错误,请重新登录!

");

}

}

classReWriteimplementsActionListener{

publicvoidactionPerformed(ActionEvente)

{

f1.setText("");

f2.setText("");

f1.requestFocus();

}

}

classCloseimplementsActionListener{

publicvoidactionPerformed(ActionEvente)

{

JButtonbt=(JButton)e.getSource();

if(bt==b3){

System.exit(0);

}

}

}

//主函数程序开始

publicstaticvoidmain(String[]args){

Loginlog=newLogin();

log.setTitle("系统登录");

log.setBounds(200,200,300,300);

log.setBackground(Color.blue);

log.setVisible(true);

}

//信息管理界面内部类进行初始化和保存

classXueShengextendsJFrameimplementsActionListener{

privateJButtoncx,zj,tc,sc,xg,tj;

publicXueSheng()

{

Containerc=this.getContentPane();

c.setLayout(newGridLayout(3,1));

c.setFont(newFont("true",Font.TRUETYPE_FONT,13));

JPanelpanel2=newJPanel();

JPanelpanel1=newJPanel();

JLabellabel1=newJLabel("欢迎进入成绩管理",SwingConstants.CENTER);

label1.setFont(newFont("true",Font.TRUETYPE_FONT,13));

label1.setForeground(Color.blue);

c.add(label1);

//添加按钮

cx=newJButton("查询");

panel2.add(cx);

zj=newJButton("增加");

panel2.add(zj);

sc=newJButton("删除");

panel2.add(sc);

tc=newJButton("退出");

panel2.add(tc);

xg=newJButton("修改");

panel1.add(xg);

tj=newJButton("统计");

panel1.add(tj);

c.add(panel2);

c.add(panel1);

cx.addActionListener(this);

zj.addActionListener(this);

sc.addActionListener(this);

xg.addActionListener(this);

tc.addActionListener(this);

tj.addActionListener(this);

this.setVisible(true);

}

publicvoidactionPerformed(ActionEvente)

{

if(e.getSource()==cx){

Findf=newFind();

}

if(e.getSource()==zj){

AddFIf=newAddFI();

}

if(e.getSource()==sc){

Deletd=newDelet();

}

if(e.getSource()==xg){

XiuGaix=newXiuGai();

}

if(e.getSource()==tc){

shutDown();

}

if(e.getSource()==tj){

Tongjit=newTongji();

}

}

privatevoidshutDown()

{

scs.stor();

JOptionPane.showMessageDialog(null,"信息已保存");

this.dispose();

}

}

//增加信息界面内部类,捕获文本框中信息创建Student对象,添加到Arraylist中,如果已存在该学号//给出提示信息,并重新添加。

classAddFIextendsJFrameimplementsActionListener{

privateJTextFieldSTNOText,SNAMEText,MAText,CHIText,JAVAText;

privateJButtonb1,b2,b3;

privateStringSTNO,SNAME,MAT,CHI,JAVA;

publicAddFI(){

super("添加学生信息");

Containerc2=this.getContentPane();

c2.setLayout(newGridLayout(3,1));

JPanelcenter=newJPanel(newGridLayout(5,2));

JPanellow=newJPanel(newFlowLayout());

JLabellabel1=newJLabel("添加学生信息",SwingConstants.CENTER);

label1.setFont(newFont("TRUE",Font.TRUETYPE_FONT,20));

c2.add(label1);

STNOText=newJTextField(30);//30列文本框

SNAMEText=newJTextField(30);

CHIText=newJTextField(30);

MAText=newJTextField(30);

JAVAText=newJTextField(30);

center.add(newJLabel("学号",SwingConstants.CENTER));//添加标签学号写在标签中间

center.add(STNOText);//添加文本框

center.add(newJLabel("姓名",SwingConstants.CENTER));

center.add(SNAMEText);

center.add(newJLabel("语文",SwingConstants.CENTER));

center.add(CHIText);

center.add(newJLabel("数学",SwingConstants.CENTER));

center.add(MAText);

center.add(newJLabel("java",SwingConstants.CENTER));

center.add(JAVAText);

c2.add(center);

b1=newJButton("添加");

b2=newJButton("清除");

b3=newJButton("退出");

low.add(b1);

low.add(b2);

low.add(b3);

c2.add(low);

//添加监听

b1.addActionListener(this);

b2.addActionListener(this);

b3.addActionListener(this);

this.setBounds(200,200,600,400);

this.setVisible(true);

this.setTitle("添加学生信息");

}

publicvoidactionPerformed(ActionEvente){

if(e.getSource()==b1){

try{

addFI();

}catch(FileNotFoundExceptione1){

e1.printStackTrace();

}catch(IOExceptione1){

e1.printStackTrace();

}

}

if(e.getSource()==b2){

clearForm();

}

if(e.getSource()==b3){

this.dispose();

}

}

privatevoidaddFI()throwsFileNotFoundException,IOException{

STNO=STNOText.getText();

SNAME=SNAMEText.getText();

CHI=CHIText.getText();

MAT=MAText.getText();

JAVA=JAVAText.getText();

if(STNO.length()==0||SNAME.length()==0||MAT.length()==0

||JAVA.length()==0||CHI.length()==0)

JOptionPane.showMessageDialog(this,"请添加完全信息");

else{

Studenta=newStudent(SNA

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1