I have a file resultados.txt
where is the id of both teams and how many goals each scored in the game.
Through this file you create another file where the team's name is, the total points of that team, how many victories it had, how many draws, how many losses, how many goals it has scored and how many goals it scored, ordered from the team that has the most points to the one that has less.
And I wanted to do a function that would do me this by giving the results file as input.
Rules:
- The winning team adds 3 points.
- In case of a tie, each team adds 1 point.
- Defeat sum 0.
Code:
public int[] CalculoClassificacao(int[]array) {
int i = 0;
int[] arrayClass = new int[7];
while(i<array.length) {
array[i] = i * 2;
i++;
}
try {
String nomeFicheiroResultados = "classificacao-final.txt";
String newLine = System.getProperty("file.separator");
File ficheiro = new File(nomeFicheiroResultados);
FileWriter escritor = new FileWriter(ficheiro);
for(int j=0; j<array.length; j++) {
String texto = array[j]+ newLine;
arrayClass = array;
escritor.write(texto);
}
escritor.close();
} catch(IOException err) {
System.out.println("Ocorreu um erro: " + err);
}
return arrayClass;
}
CSV file:
1;5;2;1
2;4;0;4