软件工程作业二

软件工程 作业二

1.码云项目地址

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

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掌握上的许多漏洞,最后虽然完成的很一般并且很繁琐不过这次作业带给了我与平常不同的体验,更有一种项目感,我觉得收获颇多。

posted @ 2018-09-17 20:28  鸡肉味嘎嘣脆  阅读(174)  评论(4编辑  收藏  举报