下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、页眉目录1 设计目的及内容要求12 系统总体设计13 系统详细设计24 运行结果及分析17致谢22参考文献22页脚页眉简单学生成绩管理系统的设计与实现1 设计目的及内容要求1、 设计目的:巩固和加深学生对高级语言程序设计课程的基本知识的理解和掌握,掌握java 语言编程和程序调试的基本技能,利用 java 语言进行基本的软件设计,提高运用java 语言解决实际问题的能力。2、 内容要求实现学生成绩的管理(增、删、改、查询、持久化、成绩排序、成绩统计等功能),在文件中增加、删除、学生信息,根据学号查询、修改学生信息,统计功能求每个人的总分并按从高到低排序,通过这些操作对文件中的信息保存。2 系统
2、总体设计成功登陆系统以后, 出现成绩管理界面, 系统初始化, 可对学生成绩进行增加、 删除、查询、修改、统计,进入相应界面进行成绩管理,退出系统自动保存本次操作内容,保存信息。简易流程图:登陆成绩管理界面增加删除查询修改统计退出页脚页眉3 系统详细设计创建 Student类,设置变量及对应方法Student.java代码:packagekeshe;importjava.io.Serializable;publicclassStudentimplementsSerializableprivateStringname ;privateintnum ;privateintyuwen;privatei
3、ntshuxue;privateintjava;privateintsum =0;publicStudent()publicStudent(String name,int num, int yuwen, int shuxue,int java) super();this .name= name;this .num= num;this .yuwen= yuwen;this .shuxue= shuxue;this .java= java;publicString getName() returnname;publicvoidsetName(String name) this .name= nam
4、e;publicint getNum() returnnum ;publicvoidsetNum(int num) this .num= num;publicint getYuwen() returnyuwen;publicvoidsetYuwen(int yuwen) 页脚页眉this .yuwen= yuwen;publicint getShuxue() returnshuxue ;publicvoidsetShuxue(int shuxue) this .shuxue= shuxue;publicint getJava() returnjava ;publicvoidsetJava(in
5、t java) this .java= java;publicint getSum() returnsum ;publicvoidsetSum( int sum) this .sum = sum;publicString toString() returnStudent name=+ name+ , num=+ num+ , yuwen=+ yuwen+ , shuxue= + shuxue + , java= + java + , sum= + sum + ;Student管理类 StuC ,创建对应方法,实现对Student对象的操作(增、删、改、查询、持久化、成绩排序、成绩统计等功能)供
6、其对象调用。StuC.java代码package keshe;import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.FileReader;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream
7、;import java.util.ArrayList;页脚页眉public class StuC ArrayList al=new ArrayList();File file = new File(e:/mydata.dat);/ 添加public void adds(Student s)al.add(s);/ 删除public void del(int n)for(int i=0;ial.size();i+)if(al.get(i).getNum()=n)al.remove(i);/ 求总分public void sum()for(int i=0;ial.size();i+)al.get(
8、i).setSum(al.get(i).getJava()+al.get(i).getShuxue()+al.get(i).getYuwen();/ 排序public void sort() for (int i = 0; i al.size(); i+) for (int j = 0; j al.size()-1-i; j+) if (al.get(j).getSum() al.get(j+1).getSum() Object o=al.get(j);al.set(j, al.get(j+1);al.set(j+1, (Student) o);public void paint()for(i
9、nt i=0;ial.size();i+)System.out.println(al.get(i);public String toString() return StuC al= + al + ;/ 输出流public void stor()页脚页眉ObjectOutputStream out = null;try out = new ObjectOutputStream(new FileOutputStream(file);out.writeObject(al);out.close(); catch (FileNotFoundException e) e.printStackTrace()
10、; catch (IOException e) e.printStackTrace();/ 输入流public void read()ObjectInputStream in = null;try in = new ObjectInputStream(new FileInputStream(file);try al = (ArrayList)in.readObject(); catch (ClassNotFoundException e) al=null;in.close(); catch (FileNotFoundException e) File file = new File(e:/my
11、data.dat); catch (IOException e) e.printStackTrace();/ 查找public Student find(int n)for(int i=0;ial.size();i+)if(al.get(i).getNum()=n)return al.get(i);页脚页眉return null;登陆界面及成绩管理的所有界面,同过创建StuC 的对象,调用其方法实现成绩管理代码:package keshe;import java.awt.*;import java.awt.event.*;import java.io.FileNotFoundException
12、;import java.io.IOException;import javax.swing.*;public class Login extends JFrameprivate TextField f1;private TextField f2;private JButton b1;private JButton b2;private JButton b3;StuC scs=new StuC();/ 登陆界面public Login()Container cp=getContentPane();/容器cp.setLayout(new GridLayout(3,1);/三行一列布局Label
13、l1=new Label(用户名 );Label l2=new Label(密码 );Panel p1=new Panel();Panel p2=new Panel();Panel p3=new Panel();f1=new TextField(10);f2=new TextField(10);f2.setEchoChar(*);/回显字符为 *b1=new JButton(登录 );b2=new JButton(重置 );b3=new JButton(退出 );p1.add(l1);/第一行添加label 1p1.add(f1);p2.add(l2);p2.add(f2);p3.add(b1
14、);p3.add(b2);页脚页眉p3.add(b3);cp.add(p1);cp.add(p2);cp.add(p3);b1.addActionListener(new Enter();b2.addActionListener(new ReWrite();b3.addActionListener(new Close();class Enter implements ActionListenerpublic void actionPerformed(ActionEvent e)if(f1.getText().equals(yazhou)&(f2.getText().equals(123456)
15、scs.read();/初始化,从文件读入信息XueShengframe1 = new XueSheng();frame1.setBounds(200, 200, 300, 300);frame1.setVisible(true);else JOptionPane.showMessageDialog(null, 用户名或密码错误,请重新登录!);class ReWrite implements ActionListenerpublic void actionPerformed(ActionEvent e)f1.setText();f2.setText();f1.requestFocus();c
16、lass Close implements ActionListenerpublic void actionPerformed(ActionEvent e)JButton bt=(JButton)e.getSource();if(bt=b3)System.exit(0);/ 主函数 程序开始public static void main(String args) Login log=new Login();log.setTitle(系统登录 );页脚页眉log.setBounds(200, 200, 300, 300);log.setBackground(Color.blue);log.set
17、Visible(true);/ 信息管理界面内部类 进行初始化和保存class XueSheng extends JFrame implements ActionListener private JButton cx, zj, tc, sc,xg,tj;public XueSheng()Container c = this.getContentPane();c.setLayout(new GridLayout(3, 1);c.setFont(new Font(true,Font.TRUETYPE_FONT,13);JPanel panel2 = new JPanel();JPanel pane
18、l1 = new JPanel();JLabel label1 = new JLabel(欢迎进入成绩管理,SwingConstants.CENTER);label1.setFont(new Font(true,Font.TRUETYPE_FONT,13);label1.setForeground(Color.blue);c.add(label1);/ 添加按钮cx = new JButton(查询 );panel2.add(cx);zj = new JButton(增加 );panel2.add(zj);sc = new JButton(删除 );panel2.add(sc);tc = ne
19、w JButton(退出 );panel2.add(tc);xg = new JButton(修改 );panel1.add(xg);tj = new JButton(统计 );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.s
20、etVisible(true);public void actionPerformed(ActionEvent e)页脚页眉if (e.getSource() = cx) Find f = new Find();if(e.getSource()=zj)AddFI f = new AddFI();if(e.getSource()=sc)Delet d = new Delet();if(e.getSource()=xg)XiuGai x=new XiuGai();if(e.getSource()=tc)shutDown();if(e.getSource()=tj)Tongji t=new Tong
21、ji();private void shutDown()scs.stor();JOptionPane.showMessageDialog(null, 信息已保存 ); this.dispose();/ 增加信息界面内部类,捕获文本框中信息创建Student 对象,添加到 Arraylist 中,如果已存在该学号 / 给出提示信息,并重新添加。class AddFI extends JFrame implements ActionListener private JTextField STNOText, SNAMEText, MAText, CHIText, JAVAText; private
22、JButton b1, b2, b3;private String STNO, SNAME,MAT, CHI, JAVA;public AddFI() super( 添加学生信息 );Container c2 = this.getContentPane();c2.setLayout(new GridLayout(3, 1);JPanel center = new JPanel(new GridLayout(5, 2);JPanel low = new JPanel(new FlowLayout();JLabel label1 = new JLabel(添加学生信息 , SwingConstan
23、ts.CENTER);label1.setFont(new Font(TRUE, Font.TRUETYPE_FONT, 20); c2.add(label1);STNOText = new JTextField(30);/30列文本框页脚页眉SNAMEText = new JTextField(30);CHIText = new JTextField(30);MAText = new JTextField(30);JAVAText = new JTextField(30);center.add(new JLabel(学号 , SwingConstants.CENTER);/添加标签学号写在标
24、签中间center.add(STNOText);/添加文本框center.add(new JLabel(姓名 , SwingConstants.CENTER);center.add(SNAMEText);center.add(new JLabel(语文 , SwingConstants.CENTER);center.add(CHIText);center.add(new JLabel(数学 , SwingConstants.CENTER);center.add(MAText);center.add(new JLabel(java, SwingConstants.CENTER);center.a
25、dd(JAVAText);c2.add(center);b1 = new JButton(添加 );b2 = new JButton(清除 );b3 = new JButton(退出 );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(
26、 添加学生信息 );public void actionPerformed(ActionEvent e) if (e.getSource() = b1) try addFI(); catch (FileNotFoundException e1) e1.printStackTrace(); catch (IOException e1) e1.printStackTrace();if (e.getSource() = b2) clearForm();页脚页眉if (e.getSource() = b3) this.dispose();private void addFI() throws File
27、NotFoundException, 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, 请添加完全信
28、息 );else Student a=new Student(SNAME,Integer.parseInt(STNO),Integer.parseInt(CHI),Integer.parseInt(MAT),Integer.parseInt(JAVA); int b=0;for(int i=0;iscs.al.size();i+)if(scs.al.get(i).getNum()=Integer.parseInt(STNO)b=1;if(b=0)scs.adds(a);JOptionPane.showMessageDialog(this, 添加成功 );elseJOptionPane.show
29、MessageDialog(this, 已存在 );private void clearForm() STNOText.setText();SNAMEText.setText();MAText.setText();CHIText.setText();JAVAText.setText();/ 查询信息界面内部类 ,根据输入的学号,在 arraylist 中查找对应学号的学生信息,分别输出页脚页眉class Find extends JFrame implements ActionListener private JTextField STNOText, SNAMEText, MAText, CH
30、IText, JAVAText; private String STNO;private JButton b1, b2;public Find() Container c1 = this.getContentPane();c1.setLayout(new GridLayout(4, 1);JLabel label1 = new JLabel(查询学生信息 , SwingConstants.CENTER);JLabel label0 = new JLabel( 请输入你的学号 ,SwingConstants.CENTER); JPanel pp = new JPanel(new GridLayo
31、ut(2, 1);pp.add(label1);pp.add(label0);c1.add(pp);JPanel p1 = new JPanel();STNOText = new JTextField(10);p1.add(STNOText);c1.add(p1);JPanel p2 = new JPanel();b1 = new JButton(查询 );b2 = new JButton(退出 );b1.addActionListener(this);b2.addActionListener(this);p2.add(b1);p2.add(b2);c1.add(p2);JPanel cent
32、er = new JPanel(new GridLayout(4, 2);SNAMEText = new JTextField(30);CHIText = new JTextField(30);MAText = new JTextField(30);JAVAText = new JTextField(30);center.add(new JLabel( 姓名 , SwingConstants.CENTER); center.add(SNAMEText);center.add(new JLabel( 语文 , SwingConstants.CENTER); center.add(CHIText)
33、;center.add(new JLabel( 数学 , SwingConstants.CENTER); center.add(MAText);center.add(new JLabel(java, SwingConstants.CENTER);center.add(JAVAText);c1.add(center);this.setVisible(true);this.setBounds(200, 200, 400, 300);public void actionPerformed(ActionEvent e)页脚页眉if (e.getSource() = b1) STNO = STNOTex
34、t.getText();int k=0;for(int i=0;iscs.al.size();i+)if(Integer.parseInt(STNO)=scs.al.get(i).getNum()SNAMEText.setText(scs.al.get(i).getName();MAText.setText(String.valueOf(scs.al.get(i).getShuxue();CHIText.setText(String.valueOf(scs.al.get(i).getYuwen();JAVAText.setText(String.valueOf(scs.al.get(i).ge
35、tJava();k=1;if(k=0)JOptionPane.showMessageDialog(this, 查无此人 );if (e.getSource() = b2) this.dispose();/ 删除信息界面,通过输入的学号进行查找并在 arraylist 中移除class Delet extends JFrame implements ActionListenerprivate JButton yes;private JButton cancle;private JTextField text1;private String STNO;public Delet()Container
36、 c3 = this.getContentPane();c3.setLayout(new GridLayout(3, 1);c3.setFont(new Font(true,Font.TRUETYPE_FONT,13);JPanel p1 = new JPanel();JPanel p2 = new JPanel();JLabel label1 = new JLabel( 删除学生信息 ,SwingConstants.CENTER); label1.setFont(new Font(true,Font.TRUETYPE_FONT,13); label1.setForeground(Color.
37、blue);c3.add(label1);JLabel label2 = new JLabel(请输入学号 );text1 = new JTextField(10);p1.add(label2);页脚页眉p1.add(text1);c3.add(p1);yes = new JButton(确定 );cancle = new JButton(退出 );p2.add(yes);p2.add(cancle);c3.add(p2);yes.addActionListener(this);cancle.addActionListener(this);this.setTitle( 删除学生信息 );thi
38、s.setBounds(200,200,400,300);this.setVisible(true);public void actionPerformed(ActionEvent e)if(e.getSource()=yes)delt();if(e.getSource()=cancle)this.dispose();private void delt()STNO= text1.getText();scs.del(Integer.parseInt(STNO);JOptionPane.showMessageDialog(this, 删除成功 );/ 统计界面,对 arraylist 中所有对象进
39、行求总分,并按总分从达到小排序class Tongji extends JFrame implements ActionListenerprivate JButton b1,b2;JTextArea t;public Tongji()Container c1 = this.getContentPane();c1.setLayout(new GridLayout(3, 1);JPanel p1 =new JPanel();JLabel label1 = new JLabel( 统计信息 , SwingConstants.CENTER); p1.add(label1);c1.add(p1);t=n
40、ew JTextArea();JScrollPane scroll=new JScrollPane(t);c1.add(scroll);JPanel p3=new JPanel();b1 = new JButton(统计 );页脚页眉b2 = new JButton(退出 );p3.add(b1);p3.add(b2);c1.add(p3);this.setBounds(200,200,400,300);this.setVisible(true);b1.addActionListener(this);b2.addActionListener(this);public void actionPe
41、rformed(ActionEvent e) if (e.getSource() = b1)scs.sum();scs.sort();String s=new String100;String s1= 总分从大到小 n 姓名 学号 数学 语文 java 总分 ; for(int i=0;iscs.al.size();i+)si=scs.al.get(i).getName()+scs.al.get(i).getNum()+scs.al.get(i).getShuxue()+scs.al.get(i).getYuwen()+scs.al.get(i).getJava()+scs.al.get(i)
42、.getSum();for(int i=0;iscs.al.size();i+)s1=s1+n+si;t.append(s1);if (e.getSource() = b2)this.dispose();/ 修改信息界面,捕获输入的学号,查找该生信息,直接在文本框中修改,类似添加功能冲新添加该生信息class XiuGai extends JFrame implements ActionListenerprivate JTextField STNOText, SNAMEText, MAText, CHIText, JAVAText; private JButton b1,b2,b3;publi
43、c XiuGai()Container c4 = this.getContentPane();c4.setLayout(new GridLayout(4, 1);c4.setFont(new Font(true,Font.TRUETYPE_FONT,13);页脚页眉JPanel up = new JPanel();JPanel center1 = new JPanel();JPanel center2 = new JPanel(new GridLayout(4, 2);JPanel low = new JPanel();JLabel label11 = new JLabel(需要修改的学号);
44、STNOText=new JTextField(15);up.add(label11);up.add(STNOText);c4.add(up);b1=new JButton(查找 );center1.add(b1);c4.add(center1);JLabel label21 = new JLabel(姓名 , SwingConstants.CENTER);JLabel label22 = new JLabel(数学 , SwingConstants.CENTER);JLabel label23 = new JLabel(语文 , SwingConstants.CENTER);JLabel label24 = new JLabel(java, SwingConstants.CENTER); SNAMEText=new JTextField(22);MAText=new JTextField(22);CHIText=new JTextField(22);JAVAText=new JTextField(22);center2.add(label21);center2.ad
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年郑州市管城回族区工会人员招聘考试模拟试题及答案详解
- 2026年长沙市芙蓉区工会人员招聘考试参考题库及答案详解
- 2026年辽宁省本溪市工会人员招聘考试参考试题及答案详解
- 2026年上海市徐汇区政务服务中心(窗口人员)招聘考试备考题库及答案详解
- 2026年宜昌市夷陵区医疗系统事业编人员招聘笔试备考题库及答案详解
- 2026年湖南省张家界市工会人员招聘笔试模拟试题及答案详解
- 2026海南省地质环境监测总站招聘事业编制人员2人(第一号)笔试备考试题及答案详解
- 2026年西藏自治区林芝市政务服务中心(窗口人员)招聘考试参考题库及答案详解
- 2026年衡阳市蒸湘区政务服务中心(窗口人员)招聘笔试模拟试题及答案详解
- 2026年8月四川波鸿实业有限公司招聘四川威斯卡特工业有限公司出纳岗位笔试备考题库及答案详解
- 2026年医保经办管护综合岗事业单位招聘考试笔试试题(含答案)
- 2026年新上岗护士测试题及答案
- 沪粤版八年级物理上册期末考试卷及答案解析(100分版)
- 2025四川九洲电器集团有限责任公司招聘光电系统总体工程师(校招)等岗位测试笔试历年参考题库附带答案详解
- 2025江苏南京栖霞区中考一模数学试卷及答案
- 广西卫生职业技术学院招聘考试真题2025
- 《电气控制与S7-1200PLC应用》课件 第6章S7-1200 PLC程序块
- 2026镇江市护士招聘考试题及答案
- 钢结构更换构件施工工艺流程
- 2026年河南省安阳市重点学校初一新生入学分班考试试题及答案
- 医疗器械设计转换管理手册
评论
0/150
提交评论