第一次编程作业
| 博客班级 | https://edu.cnblogs.com/campus/fzzcxy/2018SE1 |
|---|---|
| 作业要求 | https://edu.cnblogs.com/campus/fzzcxy/2018SE1/homework/11110 |
| 作业目标 | <[初步使用Git进行源代码管理] [记录整个过程并写总结]> |
| 作业源代码 | https://gitee.com/sun-guozheng/personal |
| 学号 | <211806341> |
| 一、代码的行数: | |
![]() |
|
| 二、时间长短: | |
| 流程 | 时间 |
| ---- | ---- |
| 思考 | 120min |
| 学习 | 240min |
| 编码 | 300min |
| 测试 | 150min |
| 博客 | 60min |
| 总计 | 870min |
| 三、思路: | |
| 计算上学期的java的期末成绩,这需要从两个云班课上所获的经验值进行加权计算。 | |
| 首先我们需要从HTML中获得我们的数据。 | |
| jsoup包下载:https://jsoup.org/download | |
| 导入教程:https://blog.csdn.net/qq_43597899/article/details/98744572 | |
| jsoup用法--从元素抽取属性,文本和HTML | |
| 在解析获得一个Document实例对象,并查找到一些元素之后要得在这些元素中的数据 | |
| 方法: | |
| 要取得一个属性的值,可以使用Node.attr(String key) 方法 | |
| 对于一个元素中的文本,可以使用Element.text()方法 | |
| 对于要取得元素或属性中的HTML内容,可以使用Element.html(), 或 Node.outerHtml()方法 | |
String html = "<p>An <a href='http://example.com/'><b>example</b></a> link.</p>"; |
|
Document doc = Jsoup.parse(html);//解析HTML字符串返回一个Document实现 |
|
Element link = doc.select("a").first();//查找第一个a元素 |
|
String text = doc.body().text(); // "An example link";//取得字符串中的文本 |
|
| 获取html后选择已完成的 | |
es.get(i).child(1).child(2).toString().contains("color:#8FC31F") |
|
| 将经验累加起来 | |
| ` if (es.get(i).child(1).child(0).toString().contains("课前自测")) |
if (es.get(i).child(1).child(2).toString().contains("color:#8FC31F")) {
Scanner sc = new Scanner(es.get(i).child(1).child(2).child(0).child(10).text());
temp = sc.nextInt();
my_Before = my_Before + temp;`
需要一份配置文件用于计算加权后的经验值。
Properties prop = new Properties(); prop.load(new FileInputStream("src/total.properties")); Enumeration fileName = prop.propertyNames(); double basic_Score_Before = Integer.parseInt(prop.getProperty("before")); double basic_Score_Base = Integer.parseInt(prop.getProperty("base")); double basic_Score_Test = Integer.parseInt(prop.getProperty("test")); double basic_Score_Program = Integer.parseInt(prop.getProperty("program")); double basic_Score_Add = Integer.parseInt(prop.getProperty("add"));
最后我们需要配置Git并建立本地仓库与远程仓库并将它们关联起来然后并上传
过程:
ssh -T git@gitee.com连上码云
git add <文件名>上传作业至暂存区
git commit -m"<提交信息>"将作业提交
git push提交至远程仓库
四、总结:
这次作业对于基础不够稳固的我非常困难,java的jsoup包可以解析HTML现在才知道觉得学到了很多
了解jsoup的使用方式,发现我在java上花费的时间还是太短了。只能说我平时很少做有点困难的作业,
希望通过这次让自己懂得多去思考多去研究


浙公网安备 33010602011771号