软工第一次作业
GIT地址:https://github.com/Jackiechanchan
项目相关要求
wc.exe 是一个常见的工具,它能统计文本文件的字符数、单词数和行数。这个项目要求写一个命令行程序,模仿已有wc.exe 的功能,并加以扩充,给出某程序设计语言源文件的字符数、单词数和行数。
实现一个统计程序,它能正确统计程序文件中的字符数、单词数、行数,以及还具备其他扩展功能,并能够快速地处理多个文件。
具体功能要求:
程序处理用户需求的模式为:
wc.exe [parameter] [file_name]
基本功能列表:
wc.exe -c file.c //返回文件 file.c 的字符数
wc.exe -w file.c //返回文件 file.c 的词的数目
wc.exe -l file.c //返回文件 file.c 的行数
遇到的困难及解决方法
C#很多都忘了,要重新看书
关键代码or设计说明
// 统计基本信息:字符数 单词数 行数
private void BaseCount(string filename)
{
try
{
// 打开文件
FileStream file = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
StreamReader sr = new StreamReader(file);
int nChar;
int charcount = 0;
int wordcount = 0;
int linecount = 0;
//定义一个字符数组
char[] symbol = { ' ', '\t', ',', '.', '?', '!', ':', ';', '\'', '\"', '\n', '{', '}', '(', ')', '+' ,'-',
'*', '='};
while ((nChar = sr.Read()) != -1)
{
charcount++; // 统计字符数
foreach (char c in symbol)
{
if(nChar == (int)c)
{
wordcount++; // 统计单词数
}
}
if (nChar == '\n')
{
linecount++; // 统计行数
}
}
iCharcount = charcount;
iWordcount = wordcount + 1;
iLinecount = linecount + 1;
sr.Close();
}
catch (IOException ex)
{
Console.WriteLine(ex.Message);
return;
}
}
PSP
PSP2.1 |
Personal Software Process Stages |
预估耗时(分钟) |
实际耗时(分钟) |
Planning |
计划 |
一小时 |
一小时 |
· Estimate |
· 估计这个任务需要多少时间 |
一周 |
一周 |
Development |
开发 |
3h |
3h |
· Analysis |
· 需求分析 (包括学习新技术) |
2d |
2d |
· Design Spec |
· 生成设计文档 |
3h |
3h |
· Design Review |
· 设计复审 (和同事审核设计文档) |
1h |
1h |
· Coding Standard |
· 代码规范 (为目前的开发制定合适的规范) |
2h |
2h |
· Design |
· 具体设计 |
5h |
5h |
· Coding |
· 具体编码 |
4h |
4h |
· Code Review |
· 代码复审 |
1h |
1h |
· Test |
· 测试(自我测试,修改代码,提交修改) |
2h |
2h |
Reporting |
报告 |
1h |
1h |
· Test Report |
· 测试报告 |
1h |
1h |
· Size Measurement |
· 计算工作量 |
20min |
20min |
· Postmortem & Process Improvement Plan |
· 事后总结, 并提出过程改进计划 |
30min |
30min |
合计 |
|
|
项目小结
很艰难,软工不适合我。我怀疑自己是否选错了专业