这个作业属于哪个课程 | 软工2018级计算机2班 |
---|---|
这个作业要求在哪里 | 202103226-1 编程作业 |
这个作业的目标 | 学习使用git等 |
学号 | 20188421 |
目录
Gitee地址
PSP表格
PSP2.1 | Personal Software Process Stages | 预估耗时(分钟) | 实际耗时(分钟) |
---|---|---|---|
Planning | 计划 | 15 | 25 |
• Estimate | • 估计这个任务需要多少时间 | 900 | 1500 |
Development | 开发 | 150 | 200 |
• Analysis | • 需求分析 (包括学习新技术) | 60 | 100 |
• Design Spec | • 生成设计文档 | 30 | 40 |
• Design Review | • 设计复审 | 20 | 30 |
• Coding Standard | • 代码规范 (为目前的开发制定合适的规范) | 25 | 30 |
• Design | • 具体设计 | 40 | 50 |
• Coding | • 具体编码 | 60 | 80 |
• Code Review | • 代码复审 | 30 | 40 |
• Test | • 测试(自我测试,修改代码,提交修改) | 30 | 40 |
Reporting | 报告 | 30 | 40 |
• Test Repor | • 测试报告 | 15 | 20 |
• Size Measurement | • 计算工作量 | 5 | 10 |
• Postmortem & Process Improvement Plan | • 事后总结, 并提出过程改进计划 | 10 | 10 |
合计 | 1390 | 2215 |
代码规范制度
解题思路描述
为实现基本需求
-
读取需要统计的文件
-
统计文件统计其中的字符数、有效行数,单词数,输出出现频率最高的十个单词
这题不太会,请教了室友很多问题。
使用WordCount.java中包含 public static void main(String[] args) 方法
用read()方法按照一个字符一个字符读取,并存起来 读取排序
Lib自定义函数读取并保存
将字符读入content
public static String readFile(String filePath)
{
int flag;
StringBuffer content = new StringBuffer();
try
{
BufferedReader br = new BufferedReader(new FileReader(filePath));
while((flag=br.read()) != -1)
{
content.append((char)flag);
}
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
return content.toString();
}
字符匹配
使用正则表达式匹配
public static int getLinesNum(String str)
{
int linesNum = 0;
Matcher matcher = Pattern.compile("(^|
)\s*\S+").matcher(str);
while(matcher.find())
{
linesNum++;
}
return linesNum;
}
排序
public List<Map.Entry<String,Integer>> sortMap()
{
List<Map.Entry<String,Integer>> wordList= new ArrayList<>(wordsMap.entrySet());
Collections.sort(wordList, (o1, o2) ->
{
if (o1.getValue().equals(o2.getValue()))
{
return o1.getKey().compareTo(o2.getKey());
}
else
{
return o2.getValue()-o1.getValue();
}
});
return wordList;
}
测试
运行效果图
心路历程
这次作业学习使用git 并且感觉到做起来很费劲,很多时候都需要去查找资料或者询问室友
还是自己基础不够 得多学习 唉。同时也体会到了码云的便捷性 管理代码的方式
以后还有很长的路要走。