20188477 编程作业

这个作业属于哪个课程 https://edu.cnblogs.com/campus/zswxy/computer-science-class3-2018
这个作业的要求在那里 https://edu.cnblogs.com/campus/zswxy/computer-science-class3-2018/homework/11879
码云地址 >https://gitee.com/liaoTao123/project-java.git>
这个作业的目标 学会用GIT提交作业到仓库
参考文献 《构建之法及软件工程》
PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时(分钟)
Planning 计划 70 00+
• Estimate • 估计这个任务需要多少时间 620 900-
Development 开发 50 70+
• Analysis • 需求分析 (包括学习新技术) 130 600+
• Design Spec • 生成设计文档 40 110+
• Design Review • 设计复审 20 50+
• Coding Standard • 代码规范 (为目前的开发制定合适的规范) 50 50+
• Design • 具体设计 110 1100+
• Coding • 具体编码 60 60+
• Code Review • 代码复审 30 30+
• Test • 测试(自我测试,修改代码,提交修改) 60 120+
Reporting 报告 10 80+
• Test Repor • 测试报告 30 90+
• Size Measurement • 计算工作量 30 60+
• Postmortem & Process Improvement Plan • 事后总结, 并提出过程改进计划 50 60+
合计 1060 3000+

码云仓库与本地连接:

总结:
我感觉这个用这个软件就不用打那些命令了,很方便。

代码部分:
、、、
import java.io.;
import java.util.
;

public class WordCount {
private static final File ROOT_File =new File("C:Usersqq");
private static int count = 0;
private static Map<String,Integer> wordCount = new HashMap<>();

public static void main(String [] args) throws Exception{
	String intputFileName =  args[0];
	String outputFileName = args[1];
	File inputFile = new File(ROOT_File,intputFileName);
	File outputFile = new File(ROOT_File,outputFileName);

	// 判断是否存在:
	if(inputFile.exists()){
		doCheck(inputFile);
	}else{
		throw new RuntimeException("error");
	}
	PrintStream stream = new PrintStream(new FileOutputStream(outputFile));
	System.setOut(stream);
	show();
	System.out.println("单词数:"+obtainTotalWords());
	System.out.println("行数:"+count);
	System.out.println("字符数:"+(inputFile.length()));
	
	
}

public  static void doCheck(File inputFile) throws Exception{
	BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile)));
	String line = null;
	while(null!=(line=br.readLine())){
		incrLine();
		// 分析每一行。
		analysis(line);
	}
}

public static void show(){
	Set<Map.Entry<String, Integer>> entries = wordCount.entrySet();
	// 排序
	ArrayList<String> words = new ArrayList<>();
	for (Map.Entry<String, Integer> entry : entries) {
		words.add(entry.getValue()+"#"+entry.getKey());
	}

	// 排序
	Collections.sort(words);
	words.forEach(obj->{
		String[] split = obj.split("#");
		String str = split[1]+": "+split[0];
		System.out.println(str);
	});
}

public static void incrLine(){
	// 行数加1
	count++;
}

//总单词数
public static long obtainTotalWords(){
	long sum = 0;
	Set<Map.Entry<String, Integer>> entries = wordCount.entrySet();
	for (Map.Entry<String, Integer> entry : entries) {
		sum+=entry.getValue();
	}
	return sum;
}

// 得到每一个单词以及次数, 并且记录到Map集合中
public static void analysis(String line){
	String [] words = line.split(" ");
	for(int i=0;i<words.length;i++){
		String word = words[i].trim();
		word = word.toLowerCase();
		word = word.contains(",")||word.contains(".")?word.substring(0,word.length()-1):word;
		if(word.length()>=4&&isWord(word.substring(0,4))){
			if(wordCount.containsKey(word)){
				Integer count = wordCount.get(word);
				count++;
				wordCount.put(word,count);
			}else{
				wordCount.put(word,1);
			}
		}
	}
}

public static boolean isWord(String word){
	for(int i=0;i<word.length();i++){
		if(word.charAt(i)>=97 && word.charAt(i)<=122){
			continue;
		}else{
			return false;
		}
	}
	return true;
}

}
、、、

在桌面创建input,output两个文档:

然后用IDEA与GIT相连接在IDEA里面GIT一下就好了

执行结果:

课程总结:感觉还有好多都没有完成,比如封装,还是需要更好的学习,好好的掌握那些知识,也能说是个人能力有限,总比之前看到题目的时候强,开始看到
题目的时候脑袋都是大的,后来就慢慢的去尝试,一点一点的去做,一点点的修改代码,还是有好多不懂得后来我就去根哥(有两年工作经验)一下就帮我解决
了不懂得问题,果然大佬就是大佬呀。

原文地址:https://www.cnblogs.com/dxl1314520/p/14610735.html