202103226-1 编程作业
| 这个作业属于哪个课程 | https://edu.cnblogs.com/campus/zswxy/computer-science-class4-2018/ | 
|---|---|
| 这个作业要求在哪里 | https://edu.cnblogs.com/campus/zswxy/computer-science-class4-2018/homework/11880 | 
| 这个作业的目标 | 实现一个能够统计文本文档词频的控制台程序,进行代码优化,能够进行接口封装 | 
| 其他参考文献 | 《构建之法》《现代软件工程》 | 
1、项目链接
2、PSP表
| PSP2.1 | Personal Software Process Stages | 预估耗时 | 实际耗时 | 
|---|---|---|---|
| Planning | 计划 | 1h | 0.5h | 
| • Estimate | • 估计这个任务需要多少时间 | 2h | 3h | 
| Development | 开发 | 10h | 10h | 
| • Analysis | • 需求分析 (包括学习新技术) | 1h | 1h | 
| • Design Spec | • 生成设计文档 | 0.5h | 0.5h | 
| • Design Review | • 设计复审 | 0.5h | 0.5h | 
| • Coding Standard | • 代码规范 (为目前的开发制定合适的规范) | 0.5h | 0.5h | 
| • Design | • 具体设计 | 3h | 2h | 
| • Coding | • 具体编码 | 2h | 2h | 
| • Code Review | • 代码复审 | 0.5h | 0.5h | 
| • Test | • 测试(自我测试,修改代码,提交修改) | 1h | 0.5h | 
| Reporting | 报告 | 1h | 2h | 
| • Test Repor | • 测试报告 | 1h | 0.5h | 
| • Size Measurement | • 计算工作量 | 0.5h | 0.25h | 
| • Postmortem & Process Improvement Plan | • 事后总结, 并提出过程改进计划 | 0.5h | 0.5h | 
| 合计 | 25h | 24.25h | 
3、解题思路
通过对题目的理解
1.统计文件的字符数(对应输出第一行)
2.统计文件的单词总数(对应输出第二行)
3.统计文件的有效行数(对应输出第三行)
4.统计文件中各单词的出现次数(对应输出接下来10行)
通过网上查阅 分别写出了各种方法
实现的函数方法
public static int getCharNum(String fileName) throws IOException{}统计字符数
public static int getWordNum(String fileName) throws IOException {}统计单词数
public static int getLineNum(String fileName) throws IOException{}统计行数
4、代码规范
5、接口设计与实现过程
 switch (strings[0]){
	               case "-c":
	                   System.out.println("字符数:"+ getCharNum(strings[1]));
	                   break;
	               case "-w":
	                   System.out.println("单词数:"+ getWordNum(strings[1]));
	                   break;
	               case "-l":
	                   System.out.println("行数:"+ getLineNum(strings[1]));
	                   break;
	               default:
	                   System.out.println("请输入正确命令格式.");
	           }
6、单元测试

7、异常处理
在测试的时候,找不到文件路径,通过调试解决
8、心路历程与收获
这一次的作业是我有史以来用时最长的,主要是毫无头绪,通过大量网上搜查资料,找到了如何与git建立联系,然后进行文件的上传,这一次的作业也让我成长了许些
让我不禁感叹前路坎坷,以后的路还很长
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号