Method for calculating punctuation

Asked

Viewed 461 times

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

  • Where’s the language? Where’s the data format?

  • In java, the data is in csv format.

  • 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.

  • What you advise me to do?

  • I suggest you amaze the data in a structured format like xml or json, making it easy to read for both people and programs.

  • 3
  • @diegofm can now help?

  • And how’s your csv? You can add a few lines of it to the question as well?

  • @diegofm already added lines from my csv file

  • 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.

  • @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

  • 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.

  • @Anthonyaccioly yes that’s right. Through the team id you can get the name

  • 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.

Show 10 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.