java學(xué)生成績(jī)管理系統(tǒng)課程設(shè)計(jì)_第1頁(yè)
java學(xué)生成績(jī)管理系統(tǒng)課程設(shè)計(jì)_第2頁(yè)
java學(xué)生成績(jī)管理系統(tǒng)課程設(shè)計(jì)_第3頁(yè)
java學(xué)生成績(jī)管理系統(tǒng)課程設(shè)計(jì)_第4頁(yè)
java學(xué)生成績(jī)管理系統(tǒng)課程設(shè)計(jì)_第5頁(yè)
已閱讀5頁(yè),還剩23頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、目 錄1設(shè)計(jì)目的及內(nèi)容要求12 系統(tǒng)總體設(shè)計(jì)13 系統(tǒng)詳細(xì)設(shè)計(jì)24 運(yùn)行結(jié)果及分析17致謝21參考文獻(xiàn)22簡(jiǎn)單學(xué)生成績(jī)管理系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn)1設(shè)計(jì)目的及內(nèi)容要求1、 設(shè)計(jì)目的:鞏固和加深學(xué)生對(duì)高級(jí)語(yǔ)言程序設(shè)計(jì)課程的基本知識(shí)的理解和掌握,掌握java語(yǔ)言編程和程序調(diào)試的基本技能,利用java語(yǔ)言進(jìn)行基本的軟件設(shè)計(jì),提高運(yùn)用java語(yǔ)言解決實(shí)際問(wèn)題的能力。2、 內(nèi)容要求實(shí)現(xiàn)學(xué)生成績(jī)的管理(增、刪、改、查詢、持久化、成績(jī)排序、成績(jī)統(tǒng)計(jì)等功能),在文件中增加、刪除、學(xué)生信息,根據(jù)學(xué)號(hào)查詢、修改學(xué)生信息,統(tǒng)計(jì)功能求每個(gè)人的總分并按從高到低排序,通過(guò)這些操作對(duì)文件中的信息保存。2 系統(tǒng)總體設(shè)計(jì)成功登陸系統(tǒng)以

2、后,出現(xiàn)成績(jī)管理界面,系統(tǒng)初始化,可對(duì)學(xué)生成績(jī)進(jìn)行增加、刪除、查詢、修改、統(tǒng)計(jì),進(jìn)入相應(yīng)界面進(jìn)行成績(jī)管理,退出系統(tǒng)自動(dòng)保存本次操作內(nèi)容,保存信息。簡(jiǎn)易流程圖: 登陸成績(jī)管理界面增加刪除查詢修改統(tǒng)計(jì)退出3 系統(tǒng)詳細(xì)設(shè)計(jì)創(chuàng)建Student類,設(shè)置變量及對(duì)應(yīng)方法Student.java代碼:package keshe;import java.io.Serializable;public class Student implements Serializableprivate String name;private int num;private int yuwen;private int shuxu

3、e;private int java;private int sum=0;public Student()public Student(String name, int num, int yuwen, int shuxue,int java) super(); = name;this.num = num;this.yuwen = yuwen;this.shuxue = shuxue;this.java = java;public String getName() return name;public void setName(String name) =

4、name;public int getNum() return num;public void setNum(int num) this.num = num;public int getYuwen() return yuwen;public void setYuwen(int yuwen) this.yuwen = yuwen;public int getShuxue() return shuxue;public void setShuxue(int shuxue) this.shuxue = shuxue;public int getJava() return java;public voi

5、d setJava(int java) this.java = java;public int getSum() return sum;public void setSum(int sum) this.sum = sum;public String toString() return Student name= + name + , num= + num + , yuwen= + yuwen+ , shuxue= + shuxue + , java= + java + , sum= + sum+ ;Student管理類StuC,創(chuàng)建對(duì)應(yīng)方法,實(shí)現(xiàn)對(duì)Student對(duì)象的操作(增、刪、改、查詢、持

6、久化、成績(jī)排序、成績(jī)統(tǒng)計(jì)等功能)供其對(duì)象調(diào)用。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.O

7、bjectOutputStream;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();

8、i+)al.get(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

9、paint()for(int 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.printStack

10、Trace(); 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

11、(e:/mydata.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;登陸界面及成績(jī)管理的所有界面,同過(guò)創(chuàng)建StuC的對(duì)象,調(diào)用其方法實(shí)現(xiàn)成績(jī)管理代碼: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 JFrame private 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);p3.

14、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() scs.read();/初

15、始化,從文件讀入信息 XueSheng frame1 = new XueSheng(); frame1.setBounds(200, 200, 300, 300); frame1.setVisible(true); else JOptionPane.showMessageDialog(null, 用戶名或密碼錯(cuò)誤,請(qǐng)重新登錄!);class ReWrite implements ActionListenerpublic void actionPerformed(ActionEvent e)f1.setText();f2.setText();f1.requestFocus();class Clo

16、se implements ActionListenerpublic void actionPerformed(ActionEvent e)JButton bt=(JButton)e.getSource();if(bt=b3)System.exit(0);/主函數(shù) 程序開始public static void main(String args) Login log=new Login();log.setTitle(系統(tǒng)登錄);log.setBounds(200, 200, 300, 300);log.setBackground(Color.blue);log.setVisible(true);

17、/信息管理界面內(nèi)部類 進(jìn)行初始化和保存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 panel1 = new JPane

18、l();JLabel label1 = new JLabel(歡迎進(jìn)入成績(jī)管理,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 = new JButton(退出);pane

19、l2.add(tc);xg = new JButton(修改);panel1.add(xg);tj = new JButton(統(tǒng)計(jì));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);publi

20、c 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 Tongji();private vo

21、id shutDown()scs.stor();JOptionPane.showMessageDialog(null, 信息已保存);this.dispose();/增加信息界面內(nèi)部類,捕獲文本框中信息創(chuàng)建Student對(duì)象,添加到Arraylist中,如果已存在該學(xué)號(hào)/給出提示信息,并重新添加。class AddFI extends JFrame implements ActionListener private JTextField STNOText, SNAMEText, MAText, CHIText, JAVAText;private JButton b1, b2, b3;priva

22、te String STNO, SNAME,MAT, CHI, JAVA;public AddFI() super(添加學(xué)生信息);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(添加學(xué)生信息, SwingConstants.CENTER);label1.setFont(n

23、ew 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(學(xué)號(hào), SwingConstants.CENTER);/添加標(biāo)簽學(xué)號(hào)寫在標(biāo)簽中間center.add(STNOText);/添加文本框cen

24、ter.add(new JLabel(姓名, SwingConstants.CENTER);center.add(SNAMEText);center.add(new JLabel(語(yǔ)文, SwingConstants.CENTER);center.add(CHIText);center.add(new JLabel(數(shù)學(xué), SwingConstants.CENTER);center.add(MAText);center.add(new JLabel(java, SwingConstants.CENTER);center.add(JAVAText);c2.add(center);b1 = new

25、 JButton(添加);b2 = new JButton(清除);b3 = new JButton(退出);low.add(b1);low.add(b2);low.add(b3);c2.add(low);/ 添加監(jiān)聽(tīng)b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);this.setBounds(200, 200, 600, 400);this.setVisible(true);this.setTitle(添加學(xué)生信息);public void actionPerformed(Act

26、ionEvent 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 FileNotFoundException, IOException STNO = STNOTex

27、t.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, 請(qǐng)?zhí)砑油耆畔?;else Student a=new Student(SNAME,Integer.p

28、arseInt(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.showMessageDialog(this, 已存在);private void clearForm(

29、) STNOText.setText();SNAMEText.setText();MAText.setText();CHIText.setText();JAVAText.setText();/查詢信息界面內(nèi)部類,根據(jù)輸入的學(xué)號(hào),在arraylist中查找對(duì)應(yīng)學(xué)號(hào)的學(xué)生信息,分別輸出class Find extends JFrame implements ActionListener private JTextField STNOText, SNAMEText, MAText, CHIText, JAVAText;private String STNO;private JButton b1, b

30、2;public Find() Container c1 = this.getContentPane();c1.setLayout(new GridLayout(4, 1);JLabel label1 = new JLabel(查詢學(xué)生信息, SwingConstants.CENTER);JLabel label0 = new JLabel(請(qǐng)輸入你的學(xué)號(hào),SwingConstants.CENTER);JPanel pp = new JPanel(new GridLayout(2, 1);pp.add(label1);pp.add(label0);c1.add(pp);JPanel p1 =

31、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 center = new JPanel(new GridLayout(4, 2);SNAMEText = new JTextField(

32、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(語(yǔ)文, SwingConstants.CENTER);center.add(CHIText);center.add(new JLabel(數(shù)學(xué), SwingConstants.CENTER);center.add(MAText);c

33、enter.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 = STNOText.getText();int k=0;for(int i=0;iscs.al.size();i+)if(Integer.parseInt(STNO)=s

34、cs.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).getJava();k=1;if(k=0)JOptionPane.showMessageDialog(this, 查無(wú)此人);if (e.getSource(

35、) = b2) this.dispose();/刪除信息界面,通過(guò)輸入的學(xué)號(hào)進(jìn)行查找并在arraylist中移除class Delet extends JFrame implements ActionListenerprivate JButton yes;private JButton cancle;private JTextField text1;private String STNO;public Delet()Container c3 = this.getContentPane();c3.setLayout(new GridLayout(3, 1);c3.setFont(new Font

36、(true,Font.TRUETYPE_FONT,13);JPanel p1 = new JPanel();JPanel p2 = new JPanel();JLabel label1 = new JLabel(刪除學(xué)生信息,SwingConstants.CENTER);label1.setFont(new Font(true,Font.TRUETYPE_FONT,13);label1.setForeground(Color.blue);c3.add(label1);JLabel label2 = new JLabel(請(qǐng)輸入學(xué)號(hào));text1 = new JTextField(10);p1.

37、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(刪除學(xué)生信息);this.setBounds(200,200,400,300);this.setVisible(true); public void actionPerformed(ActionEvent e)

38、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, 刪除成功);/統(tǒng)計(jì)界面,對(duì)arraylist中所有對(duì)象進(jìn)行求總分,并按總分從達(dá)到小排序class Tongji extends JFrame implements ActionListenerprivate JButton b1,b2;JTextA

39、rea t;public Tongji()Container c1 = this.getContentPane();c1.setLayout(new GridLayout(3, 1);JPanel p1 =new JPanel();JLabel label1 = new JLabel(統(tǒng)計(jì)信息, SwingConstants.CENTER);p1.add(label1);c1.add(p1);t=new JTextArea();JScrollPane scroll=new JScrollPane(t);c1.add(scroll);JPanel p3=new JPanel();b1 = new

40、 JButton(統(tǒng)計(jì));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 actionPerformed(ActionEvent e) if (e.getSource() = b1) scs.sum(); scs.sort(); String s=new String100; String s1=總

41、分從大到小n姓名 學(xué)號(hào) 數(shù)學(xué) 語(yǔ)文 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).getSum(); for(int i=0;iscs.al.size();i+) s1=s1+n+si; t.append(s1);if (e.getSource() = b2) th

42、is.dispose();/修改信息界面,捕獲輸入的學(xué)號(hào),查找該生信息,直接在文本框中修改,類似添加功能沖新添加該生信息class XiuGai extends JFrame implements ActionListenerprivate JTextField STNOText, SNAMEText, MAText, CHIText, JAVAText;private JButton b1,b2,b3;public XiuGai()Container c4 = this.getContentPane();c4.setLayout(new GridLayout(4, 1);c4.setFont

43、(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(需要修改的學(xué)號(hào));STNOText=new JTextField(15);up.add(label11);up.add(STNOText);c4.add(up);b1=new JButton(查找);cent

44、er1.add(b1);c4.add(center1);JLabel label21 = new JLabel(姓名, SwingConstants.CENTER);JLabel label22 = new JLabel(數(shù)學(xué), SwingConstants.CENTER);JLabel label23 = new JLabel(語(yǔ)文, SwingConstants.CENTER);JLabel label24 = new JLabel(java, SwingConstants.CENTER);SNAMEText=new JTextField(22);MAText=new JTextField

45、(22);CHIText=new JTextField(22);JAVAText=new JTextField(22);center2.add(label21);center2.add(SNAMEText);center2.add(label22);center2.add(MAText);center2.add(label23);center2.add(CHIText);center2.add(label24);center2.add(JAVAText);c4.add(center2);b2=new JButton(修改);b3=new JButton(退出);low.add(b2);low.

46、add(b3);c4.add(low);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);this.setTitle(修改信息);this.setBounds(200, 200, 600, 400);this.setVisible(true);public void actionPerformed(ActionEvent e) if (e.getSource() = b1) for(int i=0;iscs.al.size();i+)if(Integer.parseInt(STNOText.getText()=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).getJava();

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論