軟件工程做業二

軟件工程 做業二

1.碼雲項目地址

https://gitee.com/wangqiwen/SoftwareEngineering.gitgit

2.PSP表格

PSP2.1 我的開發流程 預估耗費時間(分鐘) 實際耗費時間(分鐘)
Planning 計劃 35 45
· Estimate 明確需求和其餘相關因素,估計每一個階段的時間成本 50 60
· Development 開發 730 810
· Analysis 需求分析 (包括學習新技術) 70 100
· Design Spec 生成設計文檔 60 50
· Design Review 設計複審 20 15
· Coding Standard 代碼規範 30
· Design 具體設計 100 80
· Coding 具體編碼 180 190
· Code Review 代碼複審 40 20
· Test 測試 (自我測試,修改代碼,提交修改) 150
Reporting 報告 80 90
· 測試報告 30 30
· 計算工做量 20 20
· 並提出過程改進計劃 30 40

3.解題思路描述

一開始仍是使用JAVA做爲基本語言。
寫出本身須要運用到的各個類,以及函數。數組

.重要函數說明

單詞數量

public static int getWordsNum(String text) {  
     String content = text.replace('\r', ' ');
     content = text.replace('\b', ' ');
     content = text.replace('\n', ' ');
     
     String [] words = content.split(" ");
     int wordCount = 0;
     
     for(int i= 0; i<words.length;i++)
     {
         if (words[i].length()<4)
             continue;
         
         int j = 0;
         for(  j =0;j<4;j++)
         { 
             char c =words[i].charAt(j);
             if(!((c>='A'&& c<='Z')||(c>='a'&& c<='z')))
                 break;
            
         }
        
         if(j==4)
             wordCount++;


     }
      
     return wordCount;
     
 }

有效行數統計

public static int getLineCount(String text)throws Exception  { // 統計有效行數


        int lineNum = 0;
         String[] line = text.split("\r\n"); // 將每一行分開放入一個字符串數組
         for (int i = 0; i < line.length; i++) { // 找出無效行,統計有效行

             if (line[i].trim().length() == 0)
                 continue;
             lineNum ++;
         }
         return lineNum;
     }

int charCount; // 字符統計

public static int getCharCount(String text) // 統計文件字符數
 {
     char c;
     int charNum = 0;
     for (int i = 0; i < text.length(); i++) {
         c = text.charAt(i); //把字符串轉化爲字符數組
         if (c >= 32 && c <= 126 || c == '\r' || c == '\n'|| c == '\t') {
             charNum++;
         }
     }
     return charNum;
 }

int wordCount; // 單詞統計

public static int getWordsCount'(String text) {函數

String content = text.replace('\r', ' ');
     content = text.replace('\b', ' ');
     content = text.replace('\n', ' ');
     
     String [] words = content.split(" ");
     int wordCount = 0;
     
     for(int i= 0; i<words.length;i++)
     {
         if (words[i].length()<4)
             continue;
         
         int j = 0;
         for(  j =0;j<4;j++)
         { 
             char c =words[i].charAt(j);
             if(!((c>='A'&& c<='Z')||(c>='a'&& c<='z')))
                 break;
            
         }
        
         if(j==4)
             wordCount++;


     }
      
     return wordCount;
     
 }

/單詞頻數

public static Map<String, Integer> getWordFreq(String text) // 統計單詞詞頻(單詞:以4個英文字母開頭,跟上字母數字符號,單詞以分隔符分割,不區分大小寫。)
{
HashMap<String, Integer> wordFreq = new HashMap<String, Integer>();性能

String content = text.replace('\r', ' ');
     content = text.replace('\b', ' ');
     content = text.replace('\n', ' ');
     
     String [] words = content.split(" ");
     
     
     for(int i= 0; i<words.length;i++)
     {
         if (words[i].length()<4)
             continue;
         
         int j = 0;
         for(  j =0;j<4;j++)
         { 
             char c =words[i].charAt(j);
             if(!((c>='A'&& c<='Z')||(c>='a'&& c<='z')))
                 break;
         }
        
         if(j==4)
         {
             words[i] = words[i].trim().toLowerCase();  // 將字符串轉化爲小寫
             if (wordFreq.get(words[i]) == null) 
                 { // 判斷以前Map中是否出現過該字符串
                     wordFreq.put(words[i], 1);
                 } 
             else
                 wordFreq.put(words[i], wordFreq.get(words[i]) + 1); 
         }
     }
     return wordFreq;
 }

6.單元測試

8.心得體會

我以前都覺得對於一個做業來講應該是以代碼爲一切,花費一切精力在代碼上,但此次要求是要按照流程來進行一步步的操做。可是發現,在對於本身寫代碼的時長以及PSP上的填寫就已經耗費了本身很大的時間,以及本身的預測時間與實際時間出入較大。關於軟件工程的單元測試與性能分析,本身掌握的確實不好。單元測試代碼不知道怎麼去實現。還有本身對JAVA掌握上的許多漏洞,最後雖然完成的很通常而且很繁瑣不過此次做業帶給了我與日常不一樣的體驗,更有一種項目感,我以爲收穫頗多。單元測試

相關文章
相關標籤/搜索