码云地址:https://gitee.com/NiBiWoWuLiao/PairProject-Javahtml
结对小伙伴姓名:林文秀
学号:201621123003
博客地址:http://www.javashuo.com/article/p-xxnjkmfg-b.htmlgit
码云截图:
数组
PSP2.1 | 开发流程 | 预估耗费时间(分钟) | 实际耗费时间(分钟) |
---|---|---|---|
Planning | 计划 | 30 | 25 |
· Estimate | 明确需求和其余相关因素,估计每一个阶段的时间成本 | 10 | 20 |
Development | 开发 | 200 | 240 |
· Analysis | 需求分析 (包括学习新技术) | 20 | 20 |
· Design Spec | 生成设计文档 | 10 | 15 |
· Design Review | 设计复审 | 10 | 45 |
· Coding Standard | 代码规范 | 30 | 25 |
· Design | 具体设计 | 30 | 50 |
· Coding | 具体编码 | 150 | 180 |
· Code Review | 代码复审 | 10 | 15 |
· Test | 测试(自我测试,修改代码,提交修改) | 30 | 55 |
Reporting | 报告 | 60 | 85 |
· | 测试报告 | 30 | 30 |
· | 计算工做量 | 30 | 25 |
· | 并提出过程改进计划 | 30 | 15 |
代码分为三大类:函数
函数分为:单元测试
ReadFromFile(String path)//读取文件学习
public BufferedReader ReadFromFile(String path) throws IOException { //读取文件 File file = new File(path); if (!file.exists() || file.isDirectory()) { System.out.println("请输入正确文件名!"); throw new FileNotFoundException(); } InputStreamReader isr = new InputStreamReader(new FileInputStream(path));// 创建一个输入流对象 BufferedReader br = new BufferedReader(isr); return br; }
WriteToFile(String path,String content)//写入文件测试
public void WriteToFile(String path,String content) { //写入文件 try { OutputStream out = new FileOutputStream(path); out.write(content.getBytes()); out.close(); } catch (Exception e) { e.printStackTrace(); } }
Phrase(int number) //统计词组而且排序编码
public String Phrase(int number) throws Exception{ if(number>lists.size()){ return "the number is too long"; } String wordGroup[] = new String[lists.size()-number+1]; for (int i = 0; i <lists.size()-number+1 ; i++) { //按number数为一组加入数组 } Map<String,Integer> treeMap =new TreeMap<String,Integer>(); for (int i = 0; i < wordGroup.length; i++) { String s = wordGroup[i]; if (!treeMap.containsKey(s)) { //不存在 } else { //已经存在 } } List<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(treeMap.entrySet()); Collections.sort(list, ((o1, o2) -> o2.getValue().compareTo(o1.getValue()))); String s[] = new String[wordGroup.length]; int i =0; for (Map.Entry<String,Integer>entry:list) { String key = entry.getKey(); Integer value = entry.getValue(); s[i] = key + ": " + value; i++; } String string = s[0]+"\n"; for (int j = 1; j <i ; j++) { string = string + s[j] + "\n"; } return string ; }
演示截图:在本次演示过程当中文本内容均为Monday Tuesday Wednesday Thursday设计
输出三个为一组的词组:
3d
输出出现频率第一的单词,并将其写入文件中
改进思路:根据上周是没有完成按模块分写而将全部的函数都放在Main类中,这周将对文件的操做和对字符的统计操做分红单个单独的类。并且本次要求增长的统计新功能有两个,一是词组统计,因为词组统计就没办法再像以前统计单词同样根据非数字字母划分,咱们的想法:根据空格划分,而后根据词组的长度进行先拼接存入一个新数组中,而后再去读这个存放词组的数组。对于自定义输出就参照了上周要求输出前十,修改成自定义输出要求的个数。
这里放上类图:
本次测试的函数着重于新增的词组部分上周实现的那些就进行了简单的正确性测试。如图:
对于按要求输出词组的测试分别进行了词组长度大于或小于或等于单词长度的三种测试:
测试读取非根目录下的本地文件
单元测试覆盖率图:
因为没有考虑输入m的数超过了单词总数报错:
解决方案并回归测试: