1 Star 0 Fork 0

skkda / personal

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Score修改.java 5.22 KB
一键复制 编辑 原始数据 按行查看 历史
Your Name 提交于 2020-09-17 23:06 . 修改代码
package score6423;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.Scanner;
import javax.swing.text.Document;
import org.jsoup.Jsoup;
import org.jsoup.select.Elements;
public class Score {
public static void main(String[] args) throws IOException {
//读取html文件
File f1 = new File("src\\score6423\\small.html");
File f2 = new File("src\\score6423\\all.html");
//读取配置文件
Properties prop = new Properties();
prop.load(new FileInputStream("src\\score6423\\total.properties"));
//
double before = Integer.parseInt(prop.getProperty("before"));
double base = Integer.parseInt(prop.getProperty("base"));
double test = Integer.parseInt(prop.getProperty("test"));
double program = Integer.parseInt(prop.getProperty("program"));
double add = Integer.parseInt(prop.getProperty("add"));
/*System.out.println(add);
System.out.println(base);
System.out.println(before);
System.out.println(program);
System.out.println(add);*/
my_score(f1, f2, before, base, test,program, add);
}
private static void my_score(File small,File all, double before,double base,double test,double program,double add) throws IOException {
//System.out.println(small);
//System.out.println(all);
//初始化自己的分数
int my_score_before = 0;
int my_score_base = 0;
int my_score_test = 0;
int my_score_program = 0;
int my_score_add = 0;
/*System.out.println(add);
System.out.println(base);
System.out.println(before);
System.out.println(program);
System.out.println(add);*/
try {
//用jsoup解析small和all文件,读取经验值
org.jsoup.nodes.Document d1 =Jsoup.parse(small,"UTF-8");
org.jsoup.nodes.Document d2 =Jsoup.parse(all,"UTF-8");
// System.out.println(d1);
// System.out.println(d2);
//对小班课的经验值进行统计
if(d1 != null) {
Elements elements = d1.getElementsByAttributeValue("class", "interaction-row");
int x = 0;
for(int i=0;i<elements.size();i++) {
if(elements.get(i).child(1).child(0).toString().contains("课堂完成")&&
elements.get(i).child(1).child(2).toString().contains("已参与&nbsp;")) {
Scanner sc = new Scanner(elements.get(i).child(1).child(2).children().get(0).children().get(7).text());
x = sc.nextInt();
my_score_base =my_score_base + x;
//System.out.println(my_score_base);
}else if(elements.get(i).child(1).child(0).toString().contains("课堂小测")&&
elements.get(i).child(1).child(2).toString().contains("已参与&nbsp;")){
Scanner sc = new Scanner(elements.get(i).child(1).child(2).children().get(0).children().get(7).text());
x = sc.nextInt();
my_score_test =my_score_test + x;
}else if(elements.get(i).child(1).child(0).toString().contains("编程题")&&
elements.get(i).child(1).child(2).toString().contains("已参与&nbsp;")){
Scanner sc = new Scanner(elements.get(i).child(1).child(2).children().get(0).children().get(7).text());
x = sc.nextInt();
my_score_program =my_score_program + x;
}else if(elements.get(i).child(1).child(0).toString().contains("附加题")&&
elements.get(i).child(1).child(2).toString().contains("已参与&nbsp;")){
Scanner sc = new Scanner(elements.get(i).child(1).child(2).children().get(0).children().get(7).text());
x = sc.nextInt();
my_score_add =my_score_add + x;
}else if(elements.get(i).child(1).child(0).toString().contains("课前自测")&&
elements.get(i).child(1).child(2).toString().contains("已参与&nbsp;")){
Scanner sc = new Scanner(elements.get(i).child(1).child(2).children().get(0).children().get(10).text());
x = sc.nextInt();
my_score_before =my_score_before + x;
}
}
}
//对大班课进行经验值的统计
if (d2 != null) {
Elements element = d2.getElementsByAttributeValue("class", "interaction-row");
int y = 0;
for(int i=0;i<element.size();i++) {
if (element.get(i).child(1).child(0).toString().contains("课前自测")&&
element.get(i).child(1).child(2).toString().contains("color:#8FC31F")) {
Scanner s = new Scanner(element.get(i).child(1).child(2).children().get(0).children().get(10).text());
y = s.nextInt();
my_score_before =my_score_before + y;
}
}
}
//计算5个活动的得分
double final_before = my_score_before/before*100;
double final_base = my_score_base/base*100;
double final_test = my_score_test/test*100;
double final_program = my_score_program/program*100;
double final_add = my_score_add/add*100;
if (final_add>=90) {
final_add=90;
}
// System.out.println(final_before);
// System.out.println(final_base);
// System.out.println(final_test);
// System.out.println(final_program);
// System.out.println(final_add);
//计算总分情况并输出
double final_score = final_before*0.25+final_base*0.3*0.95+final_test*0.2+final_program*0.1+final_add*0.05+6;
String score =new java.text.DecimalFormat("#.00").format(final_score);
System.out.println(score);
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
1
https://gitee.com/skkda/personal.git
git@gitee.com:skkda/personal.git
skkda
personal
personal
master

搜索帮助