标签:需求分析 scanner 换行 line can ann return 空行 standard
| PSP2.1 | Personal Software Process Stages | 预估耗时(分钟) | 实际耗时(分钟) |
|---|---|---|---|
| Planning | 计划 | 30 | 30 |
| · Estimate | · 估计这个任务需要多少时间 | 30 | 30 |
| Development | 开发 | 464 | 655 |
| · Analysis | · 需求分析 (包括学习新技术) | 20 | 30 |
| · Design Spec | · 生成设计文档 | 30 | 60 |
| · Design Review | · 设计复审 (和同事审核设计文档) | 60 | 60 |
| · Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | 30 | 40 |
| · Design | · 具体设计 | 30 | 60 |
| · Coding | · 具体编码 | 240 | 300 |
| · Code Review | · 代码复审 | 30 | 60 |
| · Test | · 测试(自我测试,修改代码,提交修改) | 24 | 45 |
| Reporting | 报告 | 80 | 80 |
| · Test Report | · 测试报告 | 20 | 40 |
| · Size Measurement | · 计算工作量 | 30 | 20 |
| · Postmortem & Process Improvement Plan | · 事后总结, 并提出过程改进计划 | 30 | 20 |
| 合计 | 574 | 765 |
基本要求
-c 统计文件字符数 (实现)
-w 统计文件词数 (实现)
-l 统计文件行数(实现)
扩展功能
高级功能
参数实现部分:

public class main {
public static void main(String[] args) {
CommandController commandController = new CommandController();
while (true) {
System.out.println("\n*********************************************");
System.out.println("**** -c [文件名] 返回文件字符数 ****");
System.out.println("**** -w [文件名] 返回文件词的数目 ****");
System.out.println("**** -l [文件名] 返回文件行数 ****");
System.out.println("**** -s [文件夹] 搜索文件名 ****");
System.out.println("**** -a [文件名] 统计代码行/空行/注释行 ****");
System.out.println("*********************************************");
System.out.print("请输入命令:");
Scanner s = new Scanner(System.in);
String m =s.nextLine();
String arr[]=m.split("\\s");
CommandServer server = commandController.SearchControlsCommand(arr[0]);
server.command(arr[1]);
}
}
}
public class CommandController {
public CommandServer SearchControlsCommand(String command){
CommandServer server = null;
switch (command){
case "-c": server = new CharacterCountServer();break; //返回文件字符数
case "-w": server = new WordCountServer();break; //返回文件词的数目
case "-l": server = new RowCountServer();break; //返回文件行数
case "-s": server = new ConditionFileServer();break; //搜索文件名
case "-a": server = new ComplexCountServer();break; //统计代码行 / 空行 / 注释行
default:
System.out.println("参数输入不正确");
}
return server;
}
}
测试文件:

测试结果:

进行代码覆盖率测试


整体代码覆盖是86%
标签:需求分析 scanner 换行 line can ann return 空行 standard
原文地址:https://www.cnblogs.com/TaoTaoLV1/p/9614017.html