

下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年中國低脂高鈣營養奶粉數據監測報告
- 新疆木壘縣中學2025年高三下教學調研(一)英語試題含解析
- 星海音樂學院《職業生涯發展和就業指導Ⅲ》2023-2024學年第二學期期末試卷
- 一年級數學上冊《排隊問題專項訓練》
- 甘肅省臨夏市第一中學2023-2024學年中考試題猜想數學試卷含解析
- 廣東省佛山市南海區2024年中考試題猜想數學試卷含解析
- 2024-2025新入職工安全培訓考試試題A卷附答案
- 2024-2025公司安全管理人員安全培訓考試試題含答案【培優A卷】
- 2025企業安全培訓考試試題有完整答案
- 腫瘤患者臨床營養問題與評估
- GB/T 17872-1999江海直達貨船船型系列
- GB/T 12027-2004塑料薄膜和薄片加熱尺寸變化率試驗方法
- 中醫手診培訓資料課件
- 消防主機運行記錄表(標準范本)
- DB2110T 0004-2020 遼陽地區主要樹種一元、二元立木材積表
- 應急處置措施交底
- 基于深度學習的問題鏈講座課件(44張PPT)
- Q∕GDW 12154-2021 電力安全工器具試驗檢測中心建設規范
- 第四章 金融監管(商業銀行管理-復旦大學)
- 中波發射臺搬遷建設及地網鋪設、機房設備的安裝與調整實踐
- 影像診斷學-—-總論PPT課件
評論
0/150
提交評論