下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、public String getA( 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 Strin
2、g 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, StringstdAns, String stuAns this.title = title 。this.A = A 。th
3、is.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 getB( return B 。
4、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 。public void setScore
5、(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 public void setScore(double score this.stuAns = stuAns 。public double check( return 2 。Text
6、paper/* To change 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 。pr
7、ivate ArrayList 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 。p
8、ublic void 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 = ti
9、me 。public 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.s
11、ql.Connection 。public void setScore(double score 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
12、ujn.ise.qsp.entity.TestPaper 。/* author Administrator*/public class Toolkit public static TestPaper generateTestPaper(String url, String user, String password throwsSQLException TestPaper paper = new TestPaper(。ArrayList qs = new ArrayList( 。Connection conn = DriverManager.getConnection(url, user, p
13、assword 。Statement stmt = conn.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.getSt
14、ring(5 。q.setE(rset.getString(6 。q.setStdAns(rset.getString(7 。q.setStuAns( 。q.setScore(rset.getDouble(8 。qs.add(q 。conn.close( 。paper.setQs(qs。return paper 。public void setScore(double score public static TestPaper generateTestPaper(String fname throws IOException return generateTestPaper(new File(
15、fname 。public static TestPaper generateTestPaper(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
16、 break 。Question q = new Question( 。 q.setTitle(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 。publ
17、ic static boolean saveTestPaper(TestPaper 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(
18、Toolkit.class.getName(.log(Level.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,public void setScore(double score ClassNotFoundExc
19、eption return readTestPaper(new File(fname 。public static TestPaper readTestPaper(File file throws IOException, ClassNotFoundExceptionObjectInputStream in = new ObjectInputStream(new FileInputStream(file 。TestPaper paper = (TestPaper in.readObject(。 in.close( 。return paper 。Eaxm system/* To change t
20、his template, choose Tools | Templates* and open 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
21、 javax.swing.JOptionPane 。import javax.swing.Timer 。import 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 extend
22、s javax.swing.JFrame private int time = 90 * 60 。private Timer timer 。private MultipleJDialog mdialog 。private int flag 。private TestPaper paper。private ExerciseJDialog exerdialog 。public void setScore(double score private class MoveTitle extends Thread Overridepublic void run( int w =jLabelTitle.ge
23、tWidth( 。int x = w 。int y =jLabelTitle.getY( 。while (true if (x x = w 。 else x -= 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( initCompo
24、nents( 。this.setLocationRelativeTo(null 。timer = new Timer(1000, new ActionListener( Overridepublic 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
25、 from within the constructor to initialize the form.* WARNING: Do NOT modify this code. The content of this method is always * regenerated by thepublic void setScore(double score Form Editor.*/SuppressWarnings(unchecked/ private void initComponents( jToolBar1 = new javax.swing.JToolBar( 。jButtonExit
26、 = new javax.swing.JButton( 。jLabel2 = new javax.swing.JLabel( 。 jLabelName = new 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.JPan
27、el( 。jLabelTitle = new javax.swing.JLabel( 。jMenuBar1 = new javax.swing.JMenuBar( 。jMenu1 = new javax.swing.JMenu( 。jMenuItemLogin = new javax.swing.JMenuItem( 。 jMenuItemHandin = newjavax.swing.JMenuItem( 。jSeparator1 = new javax.swing.JPopupMenu.Separator( 。 jMenuItemExit = newjavax.swing.JMenuIte
28、m( 。jMenuMultiple = new javax.swing.JMenu( 。 jMenuItemMultipleQuestion = newjavax.swing.JMenuItem( 。jMenu3 = new javax.swing.JMenu( 。jMenuItemExercise = new javax.swing.JMenuItem( 。jMenuItemAbout = new javax.swing.JMenuItem( 。setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSEse
29、tTitle(Exam System 。setIconImage(new ImageIcon(logo.jpg.getImage( 。 addWindowListener(newjava.awt.event.WindowAdapter( public void windowClosing(java.awt.event.WindowEventevt formWindowClosing(evt 。 。jToolBar1.setRollover(true 。 jButtonExit.setText(Exit 。 jButtonExit.setFocusable(false 。jButtonExit.
30、setHorizontalTextPosition(javax.swing.SwingConstants.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.
31、add(jButtonExit 。public void setScore(double score jLabel2.setText( 考生姓名: 。public void setScore(double score jLabelName.setText(jLabel3 。 jLabelTime.setText(00:00:00 。 jLabel5.setText( 剩余时间: 。javax.swing.GroupLayout imageJPanel1Layout =javax.swing.GroupLayout(imageJPanel1 。imageJPanel1.setLayout(ima
32、geJPanel1Layout 。imageJPanel1Layout.setHorizontalGroup(imageJPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING .addGap(0, 496, Short.MAX_V ALUE 。 imageJPanel1Layout.setVerticalGroup(imageJPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING .addGap(0, 2
33、68, Short.MAX_V ALUE 。jPanel1.setLayout(null 。 jLabelTitle.setBackground(new java.awt.Color(51, 0, 255 。jLabelTitle.setFont(new java.awt.Font( 华文行楷 , 1, 18 。 / NOI18NjLabelTitle.setForeground(new java.awt.Color(255, 255, 0 。jLabelTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER 。jLabel
34、Title.setText(Welcome. 。jLabelTitle.setOpaque(true 。 jPanel1.add(jLabelTitle 。jLabelTitle.setBounds(10, 10, 476, 21 。 jMenu1.setText( 操作 (O 。jMenu1.addMenuListener(new javax.swing.event.MenuListener( public voidmenuCanceled(javax.swing.event.MenuEvent evt public void menuDeselected(javax.swing.event
35、.MenuEvent evt public void menuSelected(javax.swing.event.MenuEvent evt jMenu1MenuSelected(evt 。 。jMenuItemLogin.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.CTRL_MASK 。jMenuItemLogin.setText(Login 。 jMenuItemLogin.addActionListener(newjav
36、a.awt.event.ActionListener( public void actionPerformed(java.awt.event.ActionEventevt jMenuItemLoginActionPerformed(evt 。 。jMenu1.add(jMenuItemLogin 。 jMenuItemHandin.setText(Hand In 。jMenuItemHandin.addActionListener(new java.awt.event.ActionListener( public voidactionPerformed(java.awt.event.Actio
37、nEvent evt jMenuItemHandinActionPerformed(evt 。newpublic void setScore(double score 。jMenu1.add(jMenuItemHandin 。 jMenu1.add(jSeparator1 。jMenuItemExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK 。jMenuItemExit.setText(Exit 。 jMe
38、nuItemExit.addActionListener(newjava.awt.event.ActionListener( public void actionPerformed(java.awt.event.ActionEvent evt jMenuItemExitActionPerformed(evt 。 。jMenu1.add(jMenuItemExit 。 jMenuBar1.add(jMenu1 。 jMenuMultiple.setText( 测试 。jMenuMultiple.addMenuListener(newjavax.swing.event.MenuListener(p
39、ublicvoidmenuCanceled(javax.swing.event.MenuEventevtpublicvoidmenuDeselected(javax.swing.event.MenuEventevtpublicvoidmenuSelected(javax.swing.event.MenuEvent evt jMenuMultipleMenuSelected(evt 。 。jMenuItemMultipleQuestion.setText( 多选题 . 。jMenuItemMultipleQuestion.addActionListener(new java.awt.event.
40、ActionListener( publicvoid actionPerformed(java.awt.event.ActionEvent evt jMenuItemMultipleQuestionActionPerformed(evt 。 。 jMenuMultiple.add(jMenuItemMultipleQuestion 。 jMenuBar1.add(jMenuMultiple 。jMenu3.setText(Help 。jMenuItemExercise.setText( 演算纸 。 jMenuItemExercise.addActionListener(newjava.awt.
41、event.ActionListener( public void actionPerformed(java.awt.event.ActionEvent evt jMenuItemExerciseActionPerformed(evt 。 。 jMenu3.add(jMenuItemExercise 。 jMenuItemAbout.setText(About 。jMenuItemAbout.addActionListener(new java.awt.event.ActionListener( public voidactionPerformed(java.awt.event.ActionE
42、vent evt jMenuItemAboutActionPerformed(evt 。 。 jMenu3.add(jMenuItemAbout 。 jMenuBar1.add(jMenu3 。setJMenuBar(jMenuBar1 。 javax.swing.GroupLayout layout = newjavax.swing.GroupLayout(getContentPane( 。 getContentPane(.setLayout(layout 。layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.Gr
43、oupLayout.Alignment.LEADING .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_V ALUE.addGroup(layout.createSequentialGroup( .addComponent(jLabel2 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED .addComponent(jLabelName,j
44、avax.swing.GroupLayout.PREFERRED_SIZE,91,javax.swing.GroupLayout.PREFERRED_SIZEpublic void setScore(double score .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,245,Short.MAX_VALUE.addComponent(jLabel5 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED .addCompon
45、ent(jLabelTime.addComponent(jSeparator2 .addGroup(layout.createSequentialGroup(.addContainerGap( .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING.addComponent(imageJPanel1,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_V ALUE.addCom
46、ponent(jPanel1,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_V ALUE.addContainerGap( 。layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING .addGroup(layout.createSequentialGroup(.addComponent(jToolBar1, javax.swing.Group
47、Layout.PREFERRED_SIZE, 25,javax.swing.GroupLayout.PREFERRED_SIZE.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 40,Short.MAX_VALUE.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED.addComponent(imageJP
48、anel1, javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE, javax.s
49、wing.GroupLayout.PREFERRED_SIZE.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN E.addComponent(jLabel2.addComponent(jLabelName.addComponent(jLabelTime .addComponent(jLabel5 。pack( 。/ private void jMenuIt
50、emExitActionPerformed(java.awt.event.ActionEvent evt exit( 。private void jButtonExitActionPerformed(java.awt.event.ActionEvent evt exit( 。public void setScore(double score private void formWindowClosing(java.awt.event.WindowEvent evt exit( 。private void jMenuItemAboutActionPerformed(java.awt.event.A
51、ctionEvent evt AboutJDialogabout = new AboutJDialog(this, true 。 about.setVisible(true 。private void jMenuItemLoginActionPerformed(java.awt.event.ActionEvent evt String name = JOptionPane.showInputDialog(this, Please input your name: 。if (name = null | name.equals( return 。this.jLabelName.setText(na
52、me 。try paper = Toolkit.generateTestPaper(paper.txt 。 catch (IOException ex Logger.getLogger(ExamSystem.class.getName(.log(Level.SEVERE, null, ex 。 return 。this.jLabelTitle.setText(paper.getTitle( 。new MoveTitle(.start( 。 timer.start( 。flag = 1 。private void jMenuItemMultipleQuestionActionPerformed(
53、java.awt.event.ActionEvent evt if(mdialog = null mdialog = new MultipleJDialog(this, true, paper.getQs( 。 mdialog.setVisible(true 。private void jMenuItemHandinActionPerformed(java.awt.event.ActionEvent evt double score =paper.calculateScore( 。JOptionPane.showMessageDialog(this, score 。flag = 2 。priv
54、ate void jMenu1MenuSelected(javax.swing.event.MenuEvent evt this.jMenuItemLogin.setEnabled(flag = 0 | flag = 2 。this.jMenuItemHandin.setEnabled(flag = 1 。private void jMenuMultipleMenuSelected(javax.swing.event.MenuEvent evt this.jMenuItemMultipleQuestion.setEnabled(flag = 1 。private void jMenuItemE
55、xerciseActionPerformed(java.awt.event.ActionEvent evt if (exerdialogpublic void setScore(double score = null exerdialog = new ExerciseJDialog(this, false 。 exerdialog.setVisible(true 。/* param args the command line arguments*/public static void main(String args /* Set the Nimbus look and feel */ /*
56、IfNimbus (introduced in Java SE 6 is not available, stay with the default look and feel. * Fordetails see*/try for (javax.swing.UIManager.LookAndFeelInfo infojavax.swing.UIManager.getInstalledLookAndFeels( if (Nimbus.equals(info.getName( javax.swing.UIManager.setLookAndFeel(info.getClassName( 。 brea
57、k 。 catch (ClassNotFoundException ex java.util.logging.Logger.getLogger(ExamSystem.class.getName(.log(java.util.logging.Level.SEVERE, null, ex 。 catch (InstantiationException ex java.util.logging.Logger.getLogger(ExamSystem.class.getName(.log(java.util.logging.Level.SEVERE, null, ex 。 catch (Illegal
58、AccessException ex java.util.logging.Logger.getLogger(ExamSystem.class.getName(.log(java.util.logging.Level.SEVERE, null, ex 。 catch (javax.swing.UnsupportedLookAndFeelException ex java.util.logging.Logger.getLogger(ExamSystem.class.getName(.log(java.util.logging.Level.SEVERE, null, ex 。/* Create an
59、d display the form */java.awt.EventQueue.invokeLater(new Runnable( public void run( public void setScore(double score new ExamSystem(.setVisible(true 。 。/ Variables declaration - do not modifyprivate ujn.ise.qsp.view.ImageJPanel imageJPanel1 。private javax.swing.JButton jButtonExit 。private javax.sw
60、ing.JLabel jLabel2 。private javax.swing.JLabel jLabel5 。private javax.swing.JLabel jLabelName 。private javax.swing.JLabel jLabelTime 。private javax.swing.JLabel jLabelTitle 。private javax.swing.JMenu jMenu1 。private javax.swing.JMenu jMenu3 。private javax.swing.JMenuBar jMenuBar1 。private javax.swin
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 国家开放大学《工程经济与管理》章节测试参考答案
- 潍坊市高三上学期期中考试试卷讲评
- 等差数列复习课课件公开课
- 精英模具改善提案
- 外科病人的体液和酸碱平衡失调
- 机械加工工艺培训课件一
- 浅谈对外汉语教材的编写原则
- 汽车排气系统介绍
- 2026年植保基础模拟试题及答案详解
- 2026年营养医师肠道营养支持考核模拟试题及答案详解
- 2024年杭州市委党校招聘教研人员考试真题
- 污水处理厂主要设备安装与调试研究
- 【大学课件】导游服务技能
- DL∕T 5097-2014 火力发电厂贮灰场岩土工程勘测技术规程
- 2024年营养指导员理论知识考试题库及答案
- MOOC 颈肩腰腿痛中医防治-暨南大学 中国大学慕课答案
- 福建省立医院检验报告
- 蒂森克虏伯扶梯电气原理图
- DL/T 5568-2020 配电网初步设计文件内容深度规定
- 心衰评估量表
- 5项目五 螺纹类零件的数控车削加工
评论
0/150
提交评论