软件工程做业二

软件工程 做业二

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掌握上的许多漏洞,最后虽然完成的很通常而且很繁琐不过此次做业带给了我与日常不一样的体验,更有一种项目感,我以为收获颇多。单元测试

相关文章
相关标签/搜索