我的worldcount

码云项目地址:https://gitee.com/kevinwangshilin/wc

PSP2.1

PSP阶段

预估耗时

(分钟)

实际耗时

(分钟)

Planning

计划

1h

0.5h

Estimate

 估计这个任务需要多少时间

5h

3h

Development

开发

3h

2h

 Analysis

需求分析 (包括学习新技术)

5h

3h

Design Spec

生成设计文档

2h

1h

Design Review

设计复审 (和同事审核设计文档)

2h

1h

 Coding Standard

代码规范 (为目前的开发制定合适的规范)

1h

1h

 Design

具体设计

1h

0.5h

Coding

具体编码

2h

1h

Code Review

代码复审

3h

2h

Test

测试(自我测试,修改代码,提交修改)

2h

1h

Reporting

报告

2h

1h

 Test Report

测试报告

2h

1h

Size Measurement

 计算工作量

6h

6h

Postmortem & Process Improvement Plan

事后总结, 并提出过程改进计划

2h

2h

合计

39h

26

代码说明:

public static String getOutFileName(String canshu){
boolean isNewFile = canshu.contains(" -O");
String fileName = null;
if(isNewFile){ fileName = canshu.substring(canshu.indexOf("-O")+3);}
return fileName;
}

public static void writeFile(String fileName,int data){
File file = new File(fileName);// 要写入的文件路径
if (!file.exists()) {// 判断文件是否存在
try {
file.createNewFile();// 如果文件不存在创建文件
System.out.println("文件"+file.getName()+"不存在已为您创建!");
} catch (IOException e) {
System.out.println("创建文件异常!");
e.printStackTrace();
}
} else {
System.out.println("文件"+file.getName()+"已存在!");
}


FileOutputStream fos = null;
PrintStream ps = null;
try {
fos = new FileOutputStream(file,true);// 文件输出流 追加
ps = new PrintStream(fos);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
String string = data+"\r\n";// +换行
ps.print(string); // 执行写操作
ps.close(); // 关闭流

System.out.println("文件写入完毕!");
}
public Parameter getParameter() {
String para[] = Tools.getParameters(this.string);
Parameter parameter = new Parameter();
for(String opt : para){

switch (opt){
case "-c":
parameter.setShowCharCount(true);
break;
case "-W":
parameter.setShowStringCount(true);
break;
case "-l":
parameter.setShowlineCount(true);
break;
case "-O":
parameter.setOutFileName(Tools.getOutFileName(this.string).replace(" ",""));
break;
default:
if(!parameter.getOutFileName().equals(opt)){ parameter.setFileName(opt); System.out.println(parameter.getOutFileName()+":"+opt);}

}
}

return parameter;
}
这两个一个是写入文件,另外一个是对参数进行分析。

思路:直接用java的一些函数实现

类:

测试过程:简单测试重要的函数,解析参数,文件读取,与文件写入


  

猜你喜欢

转载自www.cnblogs.com/SirPi/p/9697185.html