关键词:
1.github地址 https://github.com/zgwe/wordCount
2.
PSP2.1 |
PSP阶段 |
预估耗时 |
实际耗时 |
(分钟) |
(分钟) |
||
Planning |
计划 |
10 |
10 |
· Estimate |
· 估计这个任务需要多少时间 |
20 |
10 |
Development |
开发 |
40 |
60 |
· Analysis |
· 需求分析 (包括学习新技术) |
60 |
180 |
· Design Spec |
· 生成设计文档 |
60 |
100 |
· Design Review |
· 设计复审 (和同事审核设计文档) |
40 |
60 |
· Coding Standard |
· 代码规范 (为目前的开发制定合适的规范) |
60 |
60 |
· Design |
· 具体设计 |
300 |
420 |
· Coding |
· 具体编码 |
360 |
480 |
· Code Review |
· 代码复审 |
50 |
80 |
· Test |
· 测试(自我测试,修改代码,提交修改) |
100 |
120 |
Reporting |
报告 |
40 |
80 |
· Test Report |
· 测试报告 |
40 |
80 |
· Size Measurement |
· 计算工作量 |
20 |
10 |
· Postmortem & Process Improvement Plan |
· 事后总结, 并提出过程改进计划 |
30 |
30 |
|
合计 |
1230 |
1780
|
3.解题思路
题目是做一个类词法解析器,对目标文件进行读入,计数。
思路是接收到目标文件后,对该文件进行处理,得出所有要求的行数,单词数,字符数等,之后根据参数判断输出内容,并输出到结果文件中。
对目标文件的处理,也是词法分析器的基本功能,-a,-w,-l,-c,-o,都是判断计数的过程,
-s,-e网上找到的参考,链接如下
https://www.cnblogs.com/azhqiang/p/4596793.html JAVA 遍历文件夹下的所有文件
https://blog.csdn.net/yoany/article/details/41216715 文本分类实验中用java实现取名词和去除停用词
4.程序设计实现过程
代码组织;
最开始的设想是有3个类,wordcount,test,getargs,其中wordcount类是功能承担类,所有-a,-w,-l,-c,-o在wordcount中完成,test类作为程序入口,调用wordcount,getargs中的方法,getargs类是对参数处理的类。
代码编写中把getargs整合到test类中了,就是test类和wordcount类进行调用传参。
test类:方法:mian()方法(代码说明中介绍)
wordcount类 方法:wordcount()构造函数;init()初始化方法;
setfile(),setfile2(),getchar(),getword(),getline(),getmore(),getter和setter方法
print()输出方法
5.代码说明
main函数简易流程图:
代码:
//main函数执行基本功能
wordCount a=new wordCount(argR.get(0),argR.get(1)); if(argR2.contains("c")) //do c a.getchar(); if(argR2.contains("w")) //do w a.getword(); if(argR2.contains("l")) //do l a.getline(); if(argR2.contains("a")) //do a a.getmore(); if(argR2.contains("o")) //do o try a.print(); catch (IOException e) // TODO Auto-generated catch block e.printStackTrace();
try //对文件进行统计 File file=new File(name); BufferedReader br= new BufferedReader(new FileReader(file)); String str = null; while((str=br.readLine())!=null) countChar += str.length();//字符个数就是字符长度 countWord += str.split(",| ").length;//split() 方法用于把一个字符串分割成字符串数组,字符串数组的长度,就是单词个数 countLine++;//因为是按行读取,所以每次增加一即可计算出行的数目 str = str.trim(); if (str.matches("\\\\s*.?\\\\s*")) whiteLine++; else if (str.startsWith("/*") && !str.endsWith("*/")) commentLine++; comment = true; else if (true == comment) commentLine++; if (str.endsWith("*/")) comment = false; else if (str.startsWith("//")) commentLine++; else normalLine++; catch(Exception e) e.printStackTrace();
public void print() throws IOException /* 写入Txt文件 */ File writename; if(this.name2==null) writename = new File(".\\\\result.txt"); // 相对路径,如果没有则要建立一个新的result.txt文件 else writename=new File(".\\\\"+name2); writename.createNewFile(); // 创建新文件 BufferedWriter out = new BufferedWriter(new FileWriter(writename)); out.write(result); // \\r\\n即为换行 out.flush(); // 把缓存区内容压入文件 out.close(); // 最后记得关闭文件
6.测试设计过程
7.参考链接
http://blog.csdn.net/w4bobo/article/details/17024019
http://blog.csdn.net/ycy0706/article/details/45457311
http://rensanning.iteye.com/blog/2161201
http://blog.csdn.net/qy20115549/article/details/53588782
第四次软测作业(代码片段)
wcProgithub项目地址:https://github.com/ChAnYaNG97/wcProPSP表格:PSP2.1PSP阶段预计耗时(分钟)实际耗时(分钟)Planning计划3030.Estimate.估计这个任务需要多长时间3030Development开发285290.Analysis.需求分析(包括学习新技术)2530.DesignSpec.生成... 查看详情
软测作业--wc
项目地址:https://github.com/evilkant/WordCount 解题思路: 这个项目其实比较基础,功能实现上没什么难度,误以为只能用JAVA语言开发,我花了一个小时回顾JAVA的基础知识【1】,配置JAVA开发环境。然后就开始编程,基础... 查看详情
wordcount小组作业(代码片段)
一.github地址https://github.com/Adogssky/WordCountGroupWork 二.psp表格PSP2.1表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 ·Estimate·估计这个任务需要多少时间425 400Development开发 ·Analysis·需求分析( 查看详情
第二周作业wordcount(代码片段)
https://github.com/HuangDongPeng/WordCount.git1.1 PSPPSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 30 30·Estimate·估计这个任务需要多少时间 5h 12hDevelopment开发 2h 4h·Analysis·需求分析(包括学习新技 查看详情
第4周小组作业:wordcount优化(代码片段)
第4周小组作业:WordCount优化一、基本任务:代码编写+单元测试小组github地址 https://github.com/iwannastay/WcPro PSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划3060Estimate估计任务需要多少时间3060Development开发180240Analy... 查看详情
第二周个人作业wordcount(代码片段)
一、GitHub地址https://github.com/JasonLiu1105/WordCount二、PSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 20 20·Estimate·估计这个任务需要多少时间 2days 3daysDevelopment开发 1day 1day·Analysis·需求 查看详情
第四周作业wordcount优化(代码片段)
基本+扩展+高级 基本任务:代码编写+单元测试1.Github地址https://github.com/ChenSilence/wcPro2.PSP表格 PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 2010 ·Estimate·估计这个任务需要多少时间2010Development开发36040... 查看详情
wordcount第四周小组作业(代码片段)
一、小组GitHub地址 https://github.com/muzhailong/wcPro.git 二、PSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 3030·Estimate·估计这个任务需要多少时间 20 20Development开发 480480·Analysis·需求分析(包... 查看详情
第2周个人作业:wordcount(代码片段)
github地址https://github.com/HastingsX/SoftwareTestPSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划101·Estimate·估计这个任务需要多少时间101Development开发730890·Analysis·需求分析(包括学习新技术)6060·DesignSpec·生成设计文档2... 查看详情
第二周作业wordcount(代码片段)
github项目链接https://github.com/liqia/WordCount1.项目简介对程序设计语言源文件统计字符数、单词数、行数,统计结果以指定格式输出到默认文件中,以及其他扩展功能,并能够快速地处理多个文件。可执行程序命名为:wc.exe,该程序... 查看详情
第四周wordcount小组作业(代码片段)
一、基础功能小组github地址:https://github.com/kawoyi/Advanced-WordCounterPSP表格:接口的实现:我实现的是单词的统计模块,由Counter类完成,其中最主要的功能是由analyse()函数完成功能是将分割出单词并且加入map中供输出结果publicvoi... 查看详情
第4周小组作业:wordcount优化(代码片段)
一.GITHUB地址github地址:https://github.com/yo123abxd/wordcount2.git二.PSP表格 PSP2.1表格 PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 ·Estimate·估计这个任务需要多少时间 400-600 Developme 查看详情
第四周小组作业:wordcount优化(代码片段)
Github地址:https://github.com/skz12345/wcProPSP表格: PSPPSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划105Estimate估计这个任务需要多少时间105Development开发6050Analysis需求分析(包括学习新技术)55DesignSpec生成设计文档55DesignReview设计复审... 查看详情
第4周小组作业:wordcount优化(代码片段)
stage1:代码编写+单元测试PSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划1515Estimate估计任务需要多少时间2530Development开发100100Analysis需求分析2020DesignSpec生成设计文档2015DesignReview设计复审2015CodingStandard代码规范2015Design... 查看详情
第4周小组作业:wordcount优化(代码片段)
一、基本任务:代码编写+单元测试小组github地址 https://github.com/decadeheart/WcPlus PSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划5030Estimate估计任务需要多少时间1090Development开发180240Analysis需求分析2030DesignSpec... 查看详情
第4周小组作业:wordcount优化(代码片段)
github地址:https://github.com/JarrySmith/WordCountProPSP表格:PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 10 10·Estimate·估计这个任务需要多少时间 1010 Development开发 110 120·Analysis·需求分析(包括学习... 查看详情
第4周小组作业wordcount优化(代码片段)
github地址:https://github.com/husterC/WordCountGroupworkPSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)Planning计划 20 20·Estimate·估计这个任务需要多少时间 15 10Development开发 60 40·Analysis·需求分析( 查看详情
第4周作业:wordcount优化(代码片段)
Github地址:https://github.com/SkateCloud/wcPro1:分析整理需求,完成PSP表格PSP2.1PSP阶段预估耗时(分钟)实际耗时(分钟)>Planning计划56Estimate估计任务耗时56>Development开发4050Analysis需求分析(包括学习新技术)55Design具体设计55Codin... 查看详情