需求分析:html
不知道你們是否嘗試過這樣一種開發模式:你有一個夥伴,大家坐在一塊兒,並肩做戰,面對着同一臺顯示器,使用着同一鍵盤,同一個鼠標,大家一塊兒思考,一塊兒分析,一塊兒編程?此次,就讓咱們來體驗一下結對編程的魅力:
http://www.cnblogs.com/xinz/archive/2011/08/07/2130332.htmljava
咱們在我的做業1中,用各類語言實現了一個命令行的四則運算小程序。進一步,本次要求把這個程序作成GUI(能夠是Windows PC 上的,也能夠是Mac、Linux,web,手機上的),成爲一個有基本功能、必定價值的程序。在下面的功能需求中實現兩個:git
在軟件開發中,咱們須要大量使用工具來輔助設計,每一個環節你們都要善於學習和使用工具。設計的時候,請使用思惟導圖設計你的模塊之間的關係,參考這位同窗的思惟導圖:web
http://www.cnblogs.com/hts-technology/p/6490667.htmlexpress
程序設計:編程
在兩人合做的過程當中, 請看下面的內容小程序
a. 知足代碼風格規範和代碼設計規範(參考書第4章4.1-4.3內容)http://www.cnblogs.com/xinz/archive/2011/11/20/2255971.html
- 請重視這點,在開發時兩我的要有口頭上的溝通:「好的,咱們一塊兒在開發中遵照一塊兒承認的編碼規範」
- 請把大家約定的編碼規範文檔也提交到gitoracle
c. 理解領航員和駕駛員兩種角色關係,並在結對編程中兩我的輪流作對方的角色。兩人都必須參與本次做業的編碼工做,並在git提交日誌上體現這點。app
代碼展現:dom
static randomTest produce= new randomTest(); Vector answer = new Vector(); Vector expression=new Vector(); Vector result=new Vector(); int x=0; int time =0; Endjframe submit=new Endjframe(); public GUI() { initComponents(); } public void produceExpression() { produce.randTest(); expression.add(produce.Expression); result.add(produce.calc); } public void judge() { for(int i=0;i<Integer.parseInt(jTextField1.getText());i++) { if(answer.get(i).equals(result.get(i))) x++; } } public void MyTask() { time++; jLabel3.setText(Integer.toString(time%3600)); jLabel4.setText(Integer.toString(time%60)); jLabel4.setText(Integer.toString(time/60)); }
judge在兩個向量中的元素判斷是否相等,produceExpression用來生成式子的答案放入向量中;
Endjframe類用來展現正確答案以及輸入的答案,並對錯誤的題目進行統計
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package sizeyunsuan; /** * * @author Overwhelming */ public class Endjframe extends javax.swing.JFrame { /** * Creates new form Endjframe */ public Endjframe() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jTextField1 = new javax.swing.JTextField(); jTextField2 = new javax.swing.JTextField(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jScrollPane2 = new javax.swing.JScrollPane(); jTextArea2 = new javax.swing.JTextArea(); jScrollPane3 = new javax.swing.JScrollPane(); jTextArea3 = new javax.swing.JTextArea(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jTextField2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField2ActionPerformed(evt); } }); jTextArea1.setColumns(20); jTextArea1.setRows(5); jScrollPane1.setViewportView(jTextArea1); jTextArea2.setColumns(20); jTextArea2.setRows(5); jScrollPane2.setViewportView(jTextArea2); jTextArea3.setColumns(20); jTextArea3.setRows(5); jScrollPane3.setViewportView(jTextArea3); jLabel1.setText("正確"); jLabel2.setText("錯誤"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)))) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jTextField1, jTextField2}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap(43, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(41, 41, 41)))) ); layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel1, jLabel2, jTextField1, jTextField2}); pack(); }// </editor-fold>//GEN-END:initComponents private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jTextField2ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Endjframe.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Endjframe.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Endjframe.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Endjframe.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Endjframe().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables public static javax.swing.JLabel jLabel1; public static javax.swing.JLabel jLabel2; public static javax.swing.JScrollPane jScrollPane1; public static javax.swing.JScrollPane jScrollPane2; public static javax.swing.JScrollPane jScrollPane3; public static javax.swing.JTextArea jTextArea1; public static javax.swing.JTextArea jTextArea2; public static javax.swing.JTextArea jTextArea3; public static javax.swing.JTextField jTextField1; public static javax.swing.JTextField jTextField2; // End of variables declaration//GEN-END:variables }
程序運行:
小結感覺:
這次實驗是第一次團隊合做,在一些問題的處理上,能夠相互幫助,使得代碼的實現比單人的更順利,深入體會到團隊合做的重要性,爲之後工做打下一點基礎。
團隊圖片:
PSP:
PSP2.1 |
Personal Software Process Stages |
Time (%) Senior Student |
Time (%) |
Planning |
計劃 |
10 |
15 |
· Estimate |
估計這個任務須要多少時間 |
5 |
200 |
Development |
開發 |
10 |
30 |
· Analysis |
需求分析 (包括學習新技術) |
5 |
5 |
· Design Spec |
生成設計文檔 |
3 |
5 |
· Design Review |
設計複審 |
0 |
0 |
· Coding Standard |
代碼規範 |
3 |
10 |
· Design |
具體設計 |
10 |
20 |
· Coding |
具體編碼 |
50 |
150 |
· Code Review |
代碼複審 |
5 |
5 |
· Test |
測試(自我測試,修改代碼,提交修改) |
10 |
5 |
Reporting |
報告 |
2 |
20 |
· |
測試報告 |
1 |
5 |
· |
計算工做量 |
1 |
5 |
· |
並提出過程改進計劃 |
3 |
2
|
coding:https://coding.net/u/theouts/p/produceExpressionGUI