java考试系统源代码eaxmsystem_第1页
java考试系统源代码eaxmsystem_第2页
java考试系统源代码eaxmsystem_第3页
java考试系统源代码eaxmsystem_第4页
java考试系统源代码eaxmsystem_第5页
已阅读5页,还剩32页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Question/* * 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; private String B; private

2、 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; this.A = A; this.B = B;

3、 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 getB() return B; publ

4、ic 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; public void setS

5、core(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 change this

6、 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 ArrayList qs

7、; 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 void setTi

8、tle(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; publ

9、ic 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

10、 in 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.Conne

11、ction;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;/* * * author Administ

12、rator */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 = conn.createStat

13、ement(); 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.getString(6

14、); 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(File f

15、ile) 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.setTitl

16、e(line); 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(Test

17、Paper paper, 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(Lev

18、el.SEVERE, null, 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

19、 TestPaper readTestPaper(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

20、 the template in the editor. */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;imp

21、ort ujn.ise.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; privat

22、e Timer 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

23、 -= 5; jLabelTitle.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

24、 ActionListener() Override 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. * WA

25、RNING: Do NOT modify 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

26、javax.swing.JLabel(); jLabelTime = 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.JMen

27、uBar(); jMenu1 = new javax.swing.JMenu(); jMenuItemLogin = 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

28、 = new javax.swing.JMenuItem(); jMenu3 = new javax.swing.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).getI

29、mage(); addWindowListener(new java.awt.event.WindowAdapter() public void windowClosing(java.awt.event.WindowEvent evt) formWindowClosing(evt); ); jToolBar1.setRollover(true); jButtonExit.setText(Exit); jButtonExit.setFocusable(false); jButtonExit.setHorizontalTextPosition(javax.swing.SwingConstants.

30、CENTER); jButtonExit.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jButtonExit.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButtonExitActionPerformed(evt); ); jToolBar1.add(jButtonExit); jLabel2.setText(考生姓名:); jLabe

31、lName.setText(jLabel3); jLabelTime.setText(00:00:00); jLabel5.setText(剩余时间:); javax.swing.GroupLayout imageJPanel1Layout = new javax.swing.GroupLayout(imageJPanel1); imageJPanel1.setLayout(imageJPanel1Layout); imageJPanel1Layout.setHorizontalGroup( imageJPanel1Layout.createParallelGroup(javax.swing.

32、GroupLayout.Alignment.LEADING) .addGap(0, 496, Short.MAX_VALUE) ); imageJPanel1Layout.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, 2

33、55); jLabelTitle.setFont(new java.awt.Font(华文行楷, 1, 18); / NOI18N jLabelTitle.setForeground(new java.awt.Color(255, 255, 0); jLabelTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabelTitle.setText(Welcome.); jLabelTitle.setOpaque(true); jPanel1.add(jLabelTitle); jLabelTitle.setBou

34、nds(10, 10, 476, 21); jMenu1.setText(操作(O); jMenu1.addMenuListener(new 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(e

35、vt); ); jMenuItemLogin.setAccelerator(javax.swing.KeyStroke.getKeyStroke(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)

36、 jMenuItemLoginActionPerformed(evt); ); jMenu1.add(jMenuItemLogin); jMenuItemHandin.setText(Hand In); jMenuItemHandin.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jMenuItemHandinActionPerformed(evt); ); jMenu1.add(jMenuItemHandin);

37、 jMenu1.add(jSeparator1); jMenuItemExit.setAccelerator(javax.swing.KeyStroke.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.Act

38、ionEvent evt) jMenuItemExitActionPerformed(evt); ); jMenu1.add(jMenuItemExit); jMenuBar1.add(jMenu1); jMenuMultiple.setText(考试); jMenuMultiple.addMenuListener(new javax.swing.event.MenuListener() public void menuCanceled(javax.swing.event.MenuEvent evt) public void menuDeselected(javax.swing.event.M

39、enuEvent evt) public void menuSelected(javax.swing.event.MenuEvent evt) jMenuMultipleMenuSelected(evt); ); jMenuItemMultipleQuestion.setText(多选题.); jMenuItemMultipleQuestion.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jMenuItemMul

40、tipleQuestionActionPerformed(evt); ); jMenuMultiple.add(jMenuItemMultipleQuestion); jMenuBar1.add(jMenuMultiple); jMenu3.setText(Help); jMenuItemExercise.setText(演算纸); jMenuItemExercise.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt)

41、jMenuItemExerciseActionPerformed(evt); ); jMenu3.add(jMenuItemExercise); jMenuItemAbout.setText(About); jMenuItemAbout.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jMenuItemAboutActionPerformed(evt); ); jMenu3.add(jMenuItemAbout);

42、jMenuBar1.add(jMenu3); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane(); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jToolBar1, javax.swing.Grou

43、pLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabelName, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLay

44、out.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 245, Short.MAX_VALUE) .addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabelTime) .addComponent(jSeparator2) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParalle

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论