提交 68478a6f 编写于 作者: 222100117oyq's avatar 222100117oyq

初步完成功能二

上级 858ea852
Full Name:HART Alexander
Gender:Male
Country:Austria
-----
Full Name:LOTFI Dariush
Gender:Male
Country:Austria
-----
Full Name:SCHALLER Nikolaj
Gender:Male
Country:Austria
-----
Full Name:ABRAMOWICZ Tazman
Gender:Male
Country:Canada
-----
Full Name:BELANGER Eloise
Gender:Female
Country:Canada
Full Name:MULLER Jette
Rank:1
Score:51.60 + 52.00 + 51.75 + 46.80 + 46.80 = 248.95
-----
Full Name:DICK Elaena
Gender:Female
Country:Canada
Full Name:ROLLINSON Amy
Rank:2
Score:46.00 + 42.90 + 50.70 + 54.00 + 46.80 = 240.40
-----
Full Name:ERLAM Margo
Gender:Female
Country:Canada
Full Name:SKRZEK Kaja
Rank:3
Score:50.40 + 46.80 + 48.30 + 45.60 + 48.75 = 239.85
-----
Full Name:FUNG Katelyn
Gender:Female
Country:Canada
Full Name:BENT-ASHMEIL Desharne
Rank:4
Score:46.80 + 50.70 + 48.30 + 43.20 + 45.50 = 234.50
-----
Full Name:JASMIN Amelie-Laura
Gender:Female
Country:Canada
Rank:5
Score:50.40 + 45.50 + 43.70 + 46.80 + 43.75 = 230.15
-----
Full Name:TESSIER Benjamin
Gender:Male
Country:Canada
Full Name:BLAZOWSKA Aleksandra
Rank:6
Score:43.20 + 44.85 + 45.60 + 53.30 + 41.80 = 228.75
-----
Full Name:WILSON Aimee
Gender:Female
Country:Canada
-----
Full Name:JELINKOVA Tereza
Gender:Female
Country:Czechia
-----
Full Name:SANTIAGO Dominique
Gender:Female
Country:Czechia
-----
Full Name:ABADIA Adrian
Gender:Male
Country:Spain
-----
Full Name:ANTOLINO Valeria
Gender:Female
Country:Spain
-----
Full Name:CAMACHO DEL HOYO Carlos
Gender:Male
Country:Spain
-----
Full Name:CARVAJAL Ana
Gender:Female
Country:Spain
-----
Full Name:GARCIA BOISSIER Nicolas
Gender:Male
Country:Spain
-----
Full Name:LINAN Max
Gender:Male
Country:Spain
-----
Full Name:PAPWORTH BURREL Maria
Gender:Female
Country:Spain
-----
Full Name:RODRIGUEZ LEDESMA Jorge
Gender:Male
Country:Spain
-----
Full Name:VELAZQUEZ Rocio
Gender:Female
Country:Spain
-----
Full Name:BENT-ASHMEIL Desharne
Gender:Female
Country:Great Britain
-----
Full Name:BOND Maisie
Gender:Female
Country:Great Britain
-----
Full Name:DIXON Matthew
Gender:Male
Country:Great Britain
-----
Full Name:HEATLY James
Gender:Male
Country:Great Britain
-----
Full Name:HOULDEN Jordan Christopher
Gender:Male
Country:Great Britain
-----
Full Name:LEE Robbie
Gender:Male
Country:Great Britain
-----
Full Name:MCCABE Euan
Gender:Male
Country:Great Britain
-----
Full Name:ROLLINSON Amy
Gender:Female
Country:Great Britain
-----
Full Name:ONIKASHVILI Tornike
Gender:Male
Country:Georgia
-----
Full Name:SAKANDELIDZE Irakli
Gender:Male
Country:Georgia
-----
Full Name:SHANIDZE Mariam
Gender:Female
Country:Georgia
-----
Full Name:SHARIA Tekle
Gender:Female
Country:Georgia
-----
Full Name:TSULUKIDZE Giorgi
Gender:Male
Country:Georgia
-----
Full Name:AVILA SANCHEZ Luis Carlo
Gender:Male
Country:Germany
-----
Full Name:BARTHEL Timo
Gender:Male
Country:Germany
-----
Full Name:COORDES Carolina
Gender:Female
Country:Germany
-----
Full Name:EIKERMANN GREGORCHUK Jaden Shiloh
Gender:Male
Country:Germany
-----
Full Name:HENTSCHEL Lena
Gender:Female
Country:Germany
-----
Full Name:LUBE Alexander
Gender:Male
Country:Germany
-----
Full Name:MULLER Jette
Gender:Female
Country:Germany
-----
Full Name:OETTINGHAUS Saskia
Gender:Female
Country:Germany
-----
Full Name:PFEIF Pauline Alexandra
Gender:Female
Country:Germany
-----
Full Name:PRENZYNA Espen
Gender:Male
Country:Germany
-----
Full Name:ROSLER Ole Johannes
Gender:Male
Country:Germany
-----
Full Name:ROTHER Jana Lisa
Gender:Female
Country:Germany
-----
Full Name:RUDIGER Lars
Gender:Male
Country:Germany
-----
Full Name:WALDSTEINER Tom Laszlo
Gender:Male
Country:Germany
-----
Full Name:WASSEN Elena
Gender:Female
Country:Germany
-----
Full Name:WASSEN Christina
Gender:Female
Country:Germany
-----
Full Name:WESEMANN Moritz
Gender:Male
Country:Germany
-----
Full Name:TSIRIKOS Athanasios
Gender:Male
Country:Greece
-----
Full Name:BAEK Sunjin
Gender:Female
Country:Republic of Korea
-----
Full Name:CHOI Gangin
Gender:Male
Country:Republic of Korea
-----
Full Name:HAN Jiwoo
Gender:Female
Country:Republic of Korea
-----
Full Name:KANG Jiho
Gender:Male
Country:Republic of Korea
-----
Full Name:KIM Gyeongbin
Gender:Male
Country:Republic of Korea
-----
Full Name:LEE Yejoo
Gender:Female
Country:Republic of Korea
-----
Full Name:LEE Wonseop
Gender:Male
Country:Republic of Korea
Rank:7
Score:50.40 + 44.85 + 38.40 + 44.20 + 50.70 = 228.55
-----
Full Name:OH Sooyeon
Gender:Female
Country:Republic of Korea
-----
Full Name:JANSEN Inge
Gender:Female
Country:Netherlands
-----
Full Name:PRAASTERINK Else
Gender:Female
Country:Netherlands
-----
Full Name:VAN DUIJN Celine
Gender:Female
Country:Netherlands
-----
Full Name:BLAZOWSKA Aleksandra
Gender:Female
Country:Poland
-----
Full Name:JACHIM Filip
Gender:Male
Country:Poland
-----
Full Name:LESIAK Kacper
Gender:Male
Country:Poland
-----
Full Name:LUKASZEWICZ Robert
Gender:Male
Country:Poland
-----
Full Name:RZESZUTEK Andrzej
Gender:Male
Country:Poland
-----
Full Name:SKRZEK Kaja
Gender:Female
Country:Poland
-----
Full Name:MUSCALU Nicoleta-Angelica
Gender:Female
Country:Romania
-----
Full Name:COQUOZ Madeline
Gender:Female
Country:Switzerland
-----
Full Name:DUTOIT Guillaume
Gender:Male
Country:Switzerland
-----
Full Name:SUCKOW Jonathan
Gender:Male
Country:Switzerland
-----
Full Name:LUNDIN Amanda
Gender:Female
Country:Sweden
Rank:8
Score:45.60 + 36.80 + 46.80 + 46.80 + 46.80 = 222.80
-----
Full Name:AVANESOV Danylo
Gender:Male
Country:Ukraine
-----
Full Name:AZAROV Kyrylo
Gender:Male
Country:Ukraine
-----
Full Name:CHYZHOVSKYI Bohdan
Gender:Male
Country:Ukraine
-----
Full Name:HRYTSENKO Mark
Gender:Male
Country:Ukraine
-----
Full Name:KESAR Viktoriya
Gender:Female
Country:Ukraine
-----
Full Name:KONOVALOV Danylo
Gender:Male
Country:Ukraine
-----
Full Name:NAUMENKO Yevhen
Gender:Male
Country:Ukraine
-----
Full Name:OLIFERCHYK Stanislav
Gender:Male
Country:Ukraine
Full Name:LEE Yejoo
Rank:9
Score:43.20 + 41.40 + 43.20 + 41.60 + 39.60 = 209.00
-----
Full Name:PYSMENSKA Anna
Gender:Female
Country:Ukraine
Full Name:JELINKOVA Tereza
Rank:10
Score:46.80 + 42.90 + 41.40 + 26.40 + 38.50 = 196.00
-----
Full Name:KACHANOV Vyacheslav
Gender:Male
Country:Uzbekistan
Full Name:SHARIA Tekle
Rank:11
Score:38.40 + 41.60 + 30.00 + 30.45 + 34.10 = 174.55
-----
Full Name:MYALIN Igor
Gender:Male
Country:Uzbekistan
Full Name:SANTIAGO Dominique
Rank:12
Score:42.00 + 18.20 + 35.70 + 34.50 + 32.55 = 162.95
-----
......@@ -39,11 +39,29 @@ public class DWASearch {
// } catch (IOException e) {
// e.printStackTrace();
// }
String jsonFile = "src/data/athletes.json";
String outputFile = "output.txt";
try (BufferedWriter bw = new BufferedWriter(new FileWriter(outputFile))) {
getAthletes(jsonFile,bw);
String line = "result women 1m springboard";
String[] word = line.split(" ");
//from here
// Process the input data here
// For example, write the input data to the output file
if(word[0].equals("players")&&word.length==1)
{
String jsonFile = "src/data/athletes.json";
getAthletes(jsonFile,bw);
}else if(word[0].equals("result")){
if(word[word.length-1].equals("detail")){
}else{
String jsonFile = "src/data/women 1m springboard.json";
getResultSimple(jsonFile,bw);
}
}
} catch (IOException e) {
e.printStackTrace();
}
......@@ -65,5 +83,27 @@ public class DWASearch {
}
public static void getResultSimple(String jsonFile,BufferedWriter bw) throws IOException {
String content = FileUtils.readFileToString(new File(jsonFile), StandardCharsets.UTF_8);
JSONObject jsonObject = JSON.parseObject(content);
JSONArray jsonArray = JSON.parseArray(jsonObject.getString("Heats"));
JSONObject jsonObject1 = JSON.parseObject(jsonArray.getString(0));
JSONArray jsonArray1 = JSON.parseArray(jsonObject1.getString("Results"));
for(int i = 0 ; i < jsonArray1.size();i++){
JSONObject result = JSON.parseObject(jsonArray1.getString(i));
Double total = result.getDouble("TotalPoints");
String fullName = result.getString("FullName");
int rank = result.getIntValue("Rank");
JSONArray resultDetails = JSON.parseArray(result.getString("Dives"));
Double[] score = new Double[resultDetails.size()];
for(int j = 0 ; j < resultDetails.size();j++){
JSONObject detail = JSON.parseObject(resultDetails.getString(j));
score[j] = detail.getDouble("DivePoints");
}
ResultSimply resultSimply = new ResultSimply(fullName,rank,score,total);
bw.write(resultSimply.toString());
}
}
}
\ No newline at end of file
package org.example;
import java.util.Arrays;
public class ResultSimply {
private String FullName;
private int Rank;
private Double[] Score;
private Double TotalPoints;
public ResultSimply(String fullName, int rank, Double[] score,Double totalPoints) {
FullName = fullName;
Rank = rank;
Score = score;
TotalPoints = totalPoints;
}
@Override
public String toString() {
String ss = "Full Name:" + FullName +
"\nRank:" + Rank +
"\nScore:" + String.format("%.2f",Score[0]);
for(int i = 1 ; i < Score.length ; i++){
ss += " + " + String.format("%.2f",Score[i]);
}
ss = ss + " = " + String.format("%.2f",TotalPoints) +
"\n-----\n";
return ss;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册