首先,我知道这可能不是我想要的最复杂的方法,而是我想到的方法。
我正在尝试将Soccer / Football数据加载到数组列表中,然后创建命令让我对其进行分析。
例如,如果我想知道两支球队之间的最后一对得分,或者某个赛季某支球队进球数。
我有一个文件(6.txt),其数据以分隔,
例如“ 12/8/17”,“阿拉斯”,“拉斯帕尔马斯”,2,0,'H',22,6,9,1
我有一个承办商承接论证 然后我为每个团队提供了一个数组列表及其数据
import java.util.ArrayList;
import java.util.Scanner;
import java.io.*;
public class games {
String hTeam;
String date;
String aTeam;
int totGoals;
int hGoals, aGoals, result, points, wins, draws, losses, hShots, aShots, hShotsTarget, aShotsTarget;
public games(String date, String hTeam, String aTeam, int hGoals, int aGoals, char result, int hShots, int aShots, int hShotsTarget, int aShotsTarget) {
this.hTeam = hTeam;
this.aTeam = aTeam;
this.hGoals = hGoals;
this.aGoals = aGoals;
this.result = result;
this.hShots = hShots;
this.aShots = aShots;
this.date = date;
}
public String toString() {
String temp = "";
String result = "";
if (this.result == 'H') {
result += "won against";
}
else if(this.result == 'A') {
result += "lost to";
}
else if (this.result == 'D') {
result += "drew with";
}
temp += "On " + date + " " + hTeam + " " + result + " " + aTeam + " " + hGoals + " to " + aGoals + "\n";
return temp;
}
public static void main(String[] args) {
ArrayList<games> Alaves = new ArrayList<games>();
Scanner s = new Scanner(new File("6.txt"));
while (s.hasNext()) {
Alaves.add(new games(s.nextLine()));
}
}
}
我希望能够为每个团队创建一个数组列表,并带有一个将填充该列表的关联文件。
我的最终目标是能够使用这些数据比较两支球队,哪支球队更有可能获胜,那么让我们检查一下正面交锋和进球数等。