wordcount 优化

一、GitHub地址

GitHub地址:https://github.com/kawoyi/Advanced-WordCounter

二、psp表格

PSP2.1PSP阶段预估耗时实际耗时(分钟)实际耗时(分钟)
Planning 计划 20 15
- Estimate 估计这个任务需要多少时 20 20
Development 开发 300 240
- Analysis - 需求分析(包括学习新技术) 120 130
- Design Spec - 生成设计文档 120 90
- Design Review - 设计复审(和同事审核 设计文档) 20 15
- Coding Standard - 代码规范 (为目前的开发制定合适的规范) 20 15
- Design - 具体设计 20 20
- Coding - 具体编码 240 210
- Code Review - 代码复审 20 35
- Test - 测试(自我测试,修改代码,提交修改) 60 120
Reporting 报告 60 80
- Test Report - 测试报告 30 30
- Size Measurement - 计算工作量 20 20
- Postmortem & Process Improvement Plan - 事后总结, 并提出过程改进计划 20 30
  合计 1090 1070

 

三、个人模块及实现

我负责的是word类的建立及代码的整合。

package profile;

public class Word 
{
    private String content;
       private int times;
       private  boolean isValid;
    Word(String content,int times)
    {
        setContent(content);
        setTimes(times);
        isValid(content);
    }
   public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public int getTimes() {
        return times;
    }
    public void setTimes(int times) {
        this.times = times;
    }
    boolean isCharacter(char c){
        boolean flag=false;
        for(int i=0;i<Define.validCharacter.length;i++){
            if(c==Define.validCharacter[i]){
                flag=true;
            }
        }
        return flag;
    }

    public void isValid(String content){//单词有效性检验
        
            for(int j=0;j<content.length();j++){
            if(!isCharacter(content.charAt(j))&&!Character.isLetter(content.charAt(j)))
            {
                  isValid=false;
            }
        }
    }
}

word类的主要功能是在文章中分割单词,方便之后的调用。

package profile;

import java.io.IOException;

public class Test 
{
    public static void main(String[] args) 
    {
        // TODO Auto-generated method stub
        Counter count=new Counter(args[0],"result.txt");
        FileUnit.readFile(count.getFilepath(),count.getBuffer());
        count.analyse();
        try 
        {
            FileUnit.fileWriter(count.getOutputpath(),count.getMap());
        } catch (IOException e) 
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

四、测试用例设计及测试结果

测试程序对单词的识别分割是否正确,对各种情况下的单词进行测试,

包括纯字母单词,大写字母单词,字母和连字符组成的单词,字母和数字组成的单词,由空格分隔的单词,由符号分割的单词等等情况。

运用白盒测试的方法测试该程序是否能按照需求来分割单词。

对一个测试用例的测试如下(不逐一列举):

@Test
    public void test20(){
        ArrayList<String> result20 = new ArrayList<String>();
        result20.add("my");
        result20.add("word");
        result20.add("apple");
        assertEquals(result20,Test1.split(s20));
    }

五、小组贡献

 

posted @ 2018-04-08 22:20  懒得起昵称  阅读(161)  评论(1编辑  收藏  举报