0
I have a file resultados.txt
where is the id of the two teams and how many goals each scored in the game.
Through this file is created another file where is the name of the team, the total points of that team, how many wins had, how many draws, how many defeats, how many goals suffered and how many goals scored, ordered from the team that has more points to the one that has less.
And I wanted to do a function that would do that to me by giving the output file as input.
Rules:
- The winning team adds up to 3 points.
- In the event 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
In which lingugem? What is the format of the data that is in the file? You can edit the question by adding an example sff
– Miguel
Where’s the language? Where’s the data format?
– mau humor
In java, the data is in csv format.
– Ider Odg
Please do not add images to represent code or snippets of your file, this makes it difficult for anyone to help you test the problem.
– user28595
What you advise me to do?
– Ider Odg
I suggest you amaze the data in a structured format like xml or json, making it easy to read for both people and programs.
– Vinicius Fernandes
Read this: Manual on how NOT to ask questions
– user28595
@diegofm can now help?
– Ider Odg
And how’s your csv? You can add a few lines of it to the question as well?
– user28595
@diegofm already added lines from my csv file
– Ider Odg
Isn’t that CSV data missing, Ider? You said that each CSV file has "Team name, team total points, how many wins you had, how many draws, how many defeats, how many goals you have suffered and how many goals you have scored". Your CSV example has 4 columns.
– Anthony Accioly
@Anthonyaccioly esse CSV "Name of the team, the total points of that team, how many wins it had, how many draws, how many defeats, how many goals it suffered and how many goals it scored", will be created through another csv that is based on the results that have this format of only 4 columns! And I want to create a method that by giving that results.txt file can do that calculation to fill in the classification csv
– Ider Odg
Okay, what is this four-column CSV? Id of the first team, id of the second team, number of goals of the first team and number of goals of the second? And where will you get the team name to create the second CSV? Maybe it’s worth updating the question with all the necessary entries (explaining what each column is) and an example of the expected output.
– Anthony Accioly
@Anthonyaccioly yes that’s right. Through the team id you can get the name
– Ider Odg
Your question seems to be fine now. I gave my vote of reopening (you already have 2). When your question accumulates 5 votes of reopening, it is reopened.
– Victor Stafusa