软件工程与UML第一次个人编程作业

博客班级 https://edu.cnblogs.com/campus/fzzcxy/2018SE2
作业要求 https://www.cnblogs.com/yifelix/p/13647905.html
作业目标 学会Git的基本操作,获取网页数据进行编程计算
作业源代码 https://gitee.com/ouyang-xiaoyun/personal
学号 211806399
1. 需求分析
  • 将云班课所获得的经验值获取后进行用 Java 进行编码计算,输出最终成绩,将本地源码上传至码云。

2. 思路分析

  • 将网页中的经验值数据获取
  • 分析成绩的组成进行计算(个人获得的经验值总分 / 应得经验值总分 * 100)这个地方我习惯在纸上打了个草稿,字丑就不附图了
    • 课堂完成部分 30% (95 折)
    • 课堂小测 20%
    • 课前自测 25%
    • 编程题 10% (最高分 95 )
    • 附加题 5% (最高分 90 )
  • 将本地源码通过 Git 上传至码云
    这样分块思路可以比较清晰,一步步解决,有个大致的步骤才能知道需要做什么

3. 苦逼的码农过程(秃头警告)

  • 先将网页下载在本地(不要问为什么这么简单的一步都要写,问就是因为菜)
    • 第一个参数 small.html,是小班课上的“活动”页面下载到本地的文件名
    • 第二个参数 all.html,是大班课上的“活动”页面下载到本地的文件名
  • 解析网页内容(这里真的快要被难哭了,啥也不会,度娘救命)
// 配置文件取出元素
double allkq = (double) Integer.parseInt(properties.getProperty("before")); 
// 算出课前测试的总共的分数  
double allkt = (double) Integer.parseInt(properties.getProperty("base"));  
// 算出课堂完成部分总共的分数  
double allxc = (double) Integer.parseInt(properties.getProperty("test"));  
// 算出小测部分的总共的分数  
double allbc = (double) Integer.parseInt(properties.getProperty("program"));  
// 算出编程题部分总共的分数  
double allfj = (double) Integer.parseInt(properties.getProperty("add"));
* 筛选获得的经验值(绿色的是已经获得的),分五个部分分别存放
private static HashMap<String, Integer> getScores(File file) throws IOException {  
// TODO Auto-generated method stub  
int realkq = 0;  
int realkt = 0;  
int realxc = 0;  
int realbc = 0;  
int realfj = 0;  
String name1 = "课堂自测";  
String name2 = "课堂完成部分";  
String name3 = "课堂小测";  
String name4 = "编程题";  
String name5 = "附加题";  
String exp_regex = "\\d+";  
int exp = 0;  
org.jsoup.nodes.Document document = Jsoup.parse(file, "utf-8");  
org.jsoup.select.Elements rootRow = document.getElementsByClass("interaction-row");  
for (int i = 0; i < rootRow.size(); i++) {  			
	org.jsoup.select.Elements rowChild = rootRow.get(i).children();  
	org.jsoup.select.Elements rowChild2 = rowChild.get(1).children();  	
	org.jsoup.select.Elements rowChild2_1 = rowChild2.get(0).children();  
	org.jsoup.nodes.Element section = rowChild2_1.get(1);  
	org.jsoup.select.Elements rowChild2_3 = rowChild2.get(2).children();  
	org.jsoup.select.Elements rowChild2_3_1 = rowChild2_3.get(0).children();  
	org.jsoup.nodes.Element span7 = rowChild2_3_1.get(rowChild2_3_1.size() - 2);  
	// 已参与  
	org.jsoup.nodes.Element span8 = rowChild2_3_1.get(rowChild2_3_1.size() - 1);  
	// 经验值  
	Pattern p = Pattern.compile(exp_regex);  
	Matcher matcher = p.matcher(span8.text());  
	boolean result = matcher.find();  
	if (result) {  
		exp = Integer.parseInt(matcher.group(0));  
	}  
	if (section.text().contains(name1)) {  
		realkq += exp;  
	} else if (section.text().contains(name2)) {  
		realkt += exp;  
	} else if (section.text().contains(name3)) {  
		realxc += exp;  
	} else if (section.text().contains(name4)) {  
		realbc += exp;  
	} else if (section.text().contains(name5)) {  
		realfj += exp;  
	}  
}
* 结合配置文件分别进行计算后相加得出结果并输出
HashMap<String, Integer> smallpart = getScores(smallHtml);  
HashMap<String, Integer> allpart = getScores(allHtml);	  			 
double finalbe=(smallpart.get("realkq")+allpart.get("realkq"))*0.25;  
double finalba=(smallpart.get("realkt")+allpart.get("realkt"))*0.3*0.95;  
double finalts=(smallpart.get("realxc")+allpart.get("realxc"))*0.2;  
double finalpg=(smallpart.get("realbc")+allpart.get("realbc"))*0.1;  
double finalad =(smallpart.get("realfj")+allpart.get("realfj"))*0.05;  
double sum=finalbe+finalba+finalts+finalpg+finalad;  
System.out.println(sum);

这里为我死去的头发默哀一秒

4.通过 Git 将源码上传码云远程仓库

  • 在码云上创建远程仓库,取名:persoal
  • 通过 git config --global user.name "用户名名称" 和 git config --global user.email 邮箱指令连接 Git
  • 通过 ssh-keygen -t rsa 指令在码云上绑定SSH公钥(与这次作业关联不大,就不具体写了)
  • 通过 git clone 指令仓库的网址 将远程仓库下载到本地
  • 通过三个指令将本地仓库更新到码云仓库
    • git add .
    • git commit -m"备注"
    • git push
      输入用户名和密码,然后去码云查看是否更新成功

5.遇到的困难

  • Jsoup包的使用(获取经验值这里我感觉我都要把自己薅秃了)
  • Git 的安装使用(作为一个使用一台已经有8年历史的破旧的32位电脑的学生真的连安装软件都感到绝望)
  • 配置文件要怎么使用
  • 代码的逻辑有点乱
  • 运行代码无法实现功能,不会报错,可是还是有问题(落泪)

6.代码量、需求分析时间和编码时间

流程 时间
思路 30分钟
理清逻辑 30分钟
编程 210分钟
编写博客 120分钟
总计 390分钟
posted @ 2020-09-13 21:24  欧阳小云  阅读(260)  评论(4编辑  收藏  举报