java考试系统源代码eaxm system.docx

上传人:牧羊曲112 文档编号:3159721 上传时间:2023-03-11 格式:DOCX 页数:56 大小:46.54KB
返回 下载 相关 举报
java考试系统源代码eaxm system.docx_第1页
第1页 / 共56页
java考试系统源代码eaxm system.docx_第2页
第2页 / 共56页
java考试系统源代码eaxm system.docx_第3页
第3页 / 共56页
java考试系统源代码eaxm system.docx_第4页
第4页 / 共56页
java考试系统源代码eaxm system.docx_第5页
第5页 / 共56页
亲,该文档总共56页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《java考试系统源代码eaxm system.docx》由会员分享,可在线阅读,更多相关《java考试系统源代码eaxm system.docx(56页珍藏版)》请在三一办公上搜索。

1、java考试系统源代码eaxm systemQuestion /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package ujn.ise.qsp.entity; import java.io.Serializable; /* * * author Administrator */ public class Question implements Serializable private String title; private String A

2、; private String B; private String C; private String D; private String E; private double score; private String stdAns; private String stuAns; public Question public Question(String title, String A, String B, String C, String D, String E, double score, String stdAns, String stuAns) this.title = title

3、; this.A = A; this.B = B; this.C = C; this.D = D; this.E = E; this.score = score; this.stdAns = stdAns; this.stuAns = stuAns; public String getTitle return title; public void setTitle(String title) this.title = title; public String getA return A; public void setA(String A) this.A = A; public String

4、getB return B; public void setB(String B) this.B = B; public String getC return C; public void setC(String C) this.C = C; public String getD return D; public void setD(String D) this.D = D; public String getE return E; public void setE(String E) this.E = E; public double getScore return score; publi

5、c void setScore(double score) this.score = score; public String getStdAns return stdAns; public void setStdAns(String stdAns) this.stdAns = stdAns; public String getStuAns return stuAns; public void setStuAns(String stuAns) this.stuAns = stuAns; public double check return 2; Text paper /* * To chang

6、e this template, choose Tools | Templates * and open the template in the editor. */ package ujn.ise.qsp.entity; import java.io.Serializable; import java.util.ArrayList; /* * * author Administrator */ public class TestPaper implements Serializable private String title; private double score; private A

7、rrayList qs; private int time; private String teacher; public TestPaper public TestPaper(String title, double score, ArrayList qs, int time, String teacher) this.title = title; this.score = score; this.qs = qs; this.time = time; this.teacher = teacher; public String getTitle return title; public voi

8、d setTitle(String title) this.title = title; public double getScore return score; public void setScore(double score) this.score = score; public ArrayList getQs return qs; public void setQs(ArrayList qs) this.qs = qs; public int getTime return time; public void setTime(int time) this.time = time; pub

9、lic String getTeacher return teacher; public void setTeacher(String teacher) this.teacher = teacher; public double calculateScore double sum = 0; for (Question question : qs) sum += question.check; return sum; toolkit /* * To change this template, choose Tools | Templates * and open the template in

10、the editor. */ package ujn.ise.qsp.toolkit; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.sql

11、.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import ujn.ise.qsp.entity.Question; import ujn.ise.qsp.entity.TestPaper; /* * *

12、 author Administrator */ public class Toolkit public static TestPaper generateTestPaper(String url, String user, String password) throws SQLException TestPaper paper = new TestPaper; ArrayList qs = new ArrayList; Connection conn = DriverManager.getConnection(url, user, password); Statement stmt = co

13、nn.createStatement; String sql = select * from multiplequestion; ResultSet rset = stmt.executeQuery(sql); while (rset.next) Question q = new Question; q.setTitle(rset.getString(1); q.setA(rset.getString(2); q.setB(rset.getString(3); q.setC(rset.getString(4); q.setD(rset.getString(5); q.setE(rset.get

14、String(6); q.setStdAns(rset.getString(7); q.setStuAns(); q.setScore(rset.getDouble(8); qs.add(q); conn.close; paper.setQs(qs); return paper; public static TestPaper generateTestPaper(String fname) throws IOException return generateTestPaper(new File(fname); public static TestPaper generateTestPaper(

15、File file) throws IOException TestPaper paper = new TestPaper; ArrayList qs = new ArrayList; BufferedReader in = new BufferedReader(new FileReader(file); String line = in.readLine; paper.setTitle(line); while (true) line = in.readLine; if (line = null) break; Question q = new Question; q.setTitle(li

16、ne); q.setA(in.readLine); q.setB(in.readLine); q.setC(in.readLine); q.setD(in.readLine); q.setE(in.readLine); q.setStdAns(in.readLine); q.setStuAns(); q.setScore(Double.parseDouble(in.readLine); qs.add(q); in.close; paper.setQs(qs); return paper; public static boolean saveTestPaper(TestPaper paper,

17、String fname) ObjectOutputStream out = null; try File file = new File(fname); FileOutputStream fout = new FileOutputStream(file); out = new ObjectOutputStream(fout); out.writeObject(paper); out.close; return true; catch (IOException ex) Logger.getLogger(Toolkit.class.getName).log(Level.SEVERE, null,

18、 ex); return false; finally try out.close; catch (IOException ex) Logger.getLogger(Toolkit.class.getName).log(Level.SEVERE, null, ex); public static TestPaper readTestPaper(String fname) throws IOException, ClassNotFoundException return readTestPaper(new File(fname); public static TestPaper readTest

19、Paper(File file) throws IOException, ClassNotFoundException ObjectInputStream in = new ObjectInputStream(new FileInputStream(file); TestPaper paper = (TestPaper) in.readObject; in.close; return paper; Eaxm system /* * To change this template, choose Tools | Templates * and open the template in the e

20、ditor. */ package ujn.ise.qsp; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.ImageIcon; import javax.swing.JOptionPane; import javax.swing.Timer; import ujn.ise.

21、qsp.entity.TestPaper; import ujn.ise.qsp.toolkit.Toolkit; import ujn.ise.qsp.view.AboutJDialog; import ujn.ise.qsp.view.ExerciseJDialog; import ujn.ise.qsp.view.MultipleJDialog; /* * * author Administrator */ public class ExamSystem extends javax.swing.JFrame private int time = 90 * 60; private Time

22、r timer; private MultipleJDialog mdialog; private int flag; private TestPaper paper; private ExerciseJDialog exerdialog; private class MoveTitle extends Thread Override public void run int w = jLabelTitle.getWidth; int x = w; int y = jLabelTitle.getY; while (true) if (x -w) x = w; else x -= 5; jLabe

23、lTitle.setLocation(x, y); try Thread.sleep(50); catch (InterruptedException ex) Logger.getLogger(ExamSystem.class.getName).log(Level.SEVERE, null, ex); /* * Creates new form ExamSystem */ public ExamSystem initComponents; this.setLocationRelativeTo(null); timer = new Timer(1000, new ActionListener O

24、verride public void actionPerformed(ActionEvent e) String timestr = String.format(%02d:%02d:%02d, time- / 3600, time % 3600 / 60, time % 60); jLabelTime.setText(timestr); if (time = 0) ); flag = 0; /* * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modif

25、y this code. The content of this method is always * regenerated by the Form Editor. */ SuppressWarnings(unchecked) / private void initComponents jToolBar1 = new javax.swing.JToolBar; jButtonExit = new javax.swing.JButton; jLabel2 = new javax.swing.JLabel; jLabelName = new javax.swing.JLabel; jLabelT

26、ime = new javax.swing.JLabel; jLabel5 = new javax.swing.JLabel; jSeparator2 = new javax.swing.JSeparator; imageJPanel1 = new ujn.ise.qsp.view.ImageJPanel; jPanel1 = new javax.swing.JPanel; jLabelTitle = new javax.swing.JLabel; jMenuBar1 = new javax.swing.JMenuBar; jMenu1 = new javax.swing.JMenu; jMe

27、nuItemLogin = new javax.swing.JMenuItem; jMenuItemHandin = new javax.swing.JMenuItem; jSeparator1 = new javax.swing.JPopupMenu.Separator; jMenuItemExit = new javax.swing.JMenuItem; jMenuMultiple = new javax.swing.JMenu; jMenuItemMultipleQuestion = new javax.swing.JMenuItem; jMenu3 = new javax.swing.

28、JMenu; jMenuItemExercise = new javax.swing.JMenuItem; jMenuItemAbout = new javax.swing.JMenuItem; setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setTitle(Exam System); setIconImage(new ImageIcon(logo.jpg).getImage); addWindowListener(new java.awt.event.WindowAdapter publi

29、c void windowClosing(java.awt.event.WindowEvent evt) formWindowClosing(evt); ); jToolBar1.setRollover(true); jButtonExit.setText(Exit); jButtonExit.setFocusable(false); jButtonExit.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButtonExit.setVerticalTextPosition(javax.swing.SwingCons

30、tants.BOTTOM); jButtonExit.addActionListener(new java.awt.event.ActionListener public void actionPerformed(java.awt.event.ActionEvent evt) jButtonExitActionPerformed(evt); ); jToolBar1.add(jButtonExit); jLabel2.setText(考生姓名:); jLabelName.setText(jLabel3); jLabelTime.setText(00:00:00); jLabel5.setTex

31、t(剩余时间:); javax.swing.GroupLayout imageJPanel1Layout = javax.swing.GroupLayout(imageJPanel1); imageJPanel1.setLayout(imageJPanel1Layout); imageJPanel1Layout.setHorizontalGroup( imageJPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 496, Short.MAX_VALUE) ); image

32、JPanel1Layout.setVerticalGroup( imageJPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 268, Short.MAX_VALUE) ); jPanel1.setLayout(null); jLabelTitle.setBackground(new java.awt.Color(51, 0, 255); jLabelTitle.setFont(new java.awt.Font(华文行楷, 1, 18); / NOI18N new jL

33、abelTitle.setForeground(new java.awt.Color(255, 255, 0); jLabelTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabelTitle.setText(Welcome.); jLabelTitle.setOpaque(true); jPanel1.add(jLabelTitle); jLabelTitle.setBounds(10, 10, 476, 21); jMenu1.setText(操作(O); jMenu1.addMenuListener(n

34、ew javax.swing.event.MenuListener public void menuCanceled(javax.swing.event.MenuEvent evt) public void menuDeselected(javax.swing.event.MenuEvent evt) public void menuSelected(javax.swing.event.MenuEvent evt) jMenu1MenuSelected(evt); ); jMenuItemLogin.setAccelerator(javax.swing.KeyStroke.getKeyStro

35、ke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.CTRL_MASK); jMenuItemLogin.setText(Login); jMenuItemLogin.addActionListener(new java.awt.event.ActionListener public void actionPerformed(java.awt.event.ActionEvent evt) jMenuItemLoginActionPerformed(evt); ); jMenu1.add(jMenuItemLogin); jMen

36、uItemHandin.setText(Hand In); jMenuItemHandin.addActionListener(new java.awt.event.ActionListener public void actionPerformed(java.awt.event.ActionEvent evt) jMenuItemHandinActionPerformed(evt); ); jMenu1.add(jMenuItemHandin); jMenu1.add(jSeparator1); jMenuItemExit.setAccelerator(javax.swing.KeyStro

37、ke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK); jMenuItemExit.setText(Exit); jMenuItemExit.addActionListener(new java.awt.event.ActionListener public void actionPerformed(java.awt.event.ActionEvent evt) jMenuItemExitActionPerformed(evt); ); jMenu1.add(jMenuItemExit); jMenuBar

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

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号