第一周(2017-5-14 23:59截止)輸出階段總結博客
PSP2.1 | Personal Software Process Stages | 預估耗時(分鍾) | 實際耗時(分鍾) |
---|---|---|---|
Planning | 計划 | 20 | 30 |
Estimate | 估計這個任務需要多少時間 | 300 | 480 |
Development | 開發 | ||
Analysis | 需求分析 (包括學習新技術) | 20 | 70 |
Design Spec | 生成設計文檔 | ||
Design Review | 設計復審 (和同事審核設計文檔) | 20 | 20 |
Coding Standard | 代碼規范 (為目前的開發制定合適的規范) | 0 | 0 |
Design | 具體設計 | 30 | 30 |
Coding | 具體編碼 | 100 | 240 |
Code Review | 代碼復審 | 60 | 90 |
Test | 測試(自我測試,修改代碼,提交修改) | 60 | 100 |
Reporting | 報告 | ||
Test Report | 測試報告 | ||
Size Measurement | 計算工作量 | 300 | 480 |
Postmortem & Process Improvement Plan | 事后總結, 並提出過程改進計划 | 30 | 30 |
合計 | 480 |
需求分析(描述自己對需求的理解,以及后續擴展的可能性)
1.隨機生成題目數
2.整數運算
3.正確判題,如果錯誤,顯示正確答案
4.統計正確率
設計思路(同時輸出UML類圖)
實現過程中的關鍵代碼解釋
-
隨機生成運算:
public void setFormula() { this.a = (int) (Math.random () * 100); this.b = (int) (Math.random () * 100); switch ((int) (Math.random () * 4)) { case 0: op = '+'; result = a + b; break; case 1: op = '-'; result = a - b; break; case 2: op = '*'; result = a * b; break; case 3: op = '/'; while (this.b == 0) { this.b = (int) (Math.random () * 100); } if (a % b == 0) result = (a / b); else if (a % b != 0) result = (int)(a / b); System.out.printf ("%3.2f",result); }
-
統計正確率及判題
if((ex.result==answer&&ex.result2.isInteger())||ex.result1==answer1||ex.result2.equals(answer1)){ correct_num++; System.out.println("正確,很棒啊,再接再厲"); } else System.out.println("錯啦,正確答案是:"+ex.result+" 繼續加油哦"); accuracy = (float)correct_num/num; System.out.printf("不錯嘛,共%d題,做對%d題,正確率:%.2f,繼續加油啊",num,correct_num,accuracy*100 ); System.out.println('%'); System.out.println("想要學的更好就輸入你還想做的題目數,如果想休息了輸入0"); num=scan.nextInt(); if(num==0) flag =0;
運行過程截圖
代碼托管地址
遇到的困難及解決方法
關於除法我們在測試中一直都在出錯
-
關於它的代碼是
case 3: op = '/'; while (this.b == 0) { this.b = (int) (Math.random () * 100); } if (a % b == 0) result = (a / b); else if (a % b != 0) result = (int)(a / b); System.out.printf ("%3.2f",result);
-
a的值不是整數所以改進了代碼
result1 = (float) (a / c);
-
分母不能為0,所以再次定義一個隨機數c(在1至100之間)
this.c = generator.nextInt(99)+1;
-
改進之后的代碼
case 3: op = '/'; if (a % c == 0) result = (a / c); else result = (int) (a/c); result1 = (float) (a / c); result2.setter ( a, c ); result2 = result2.reduce_deno ( result2 ); break;
對結對的小伙伴做出評
合作的很好,我們互相幫助,有了困難問題一起找解決方法,不停的實踐、嘗試,直到達到我們的要求
我們的水平有限,所以程序寫的並不是很好,但是我們一直在改進,在測試.