<commit_before>package pt.iscte.lei.pi.firujo.scores;

import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collections;

public class HighScoreManager {

	// lista de scores
	private ArrayList<Score> scores;

	// ficheiro onde vamos guardar scores - é .dat para ninguem modificar e dar banhada nos resultados :D
	private static final String HIGHSCORE_FILE = "highscores.dat";

	ObjectOutputStream oos = null;
	ObjectInputStream ois = null;

	public HighScoreManager() {
		//se ainda nao existir o ficheiro (1o carregamento) ele cria
		File scoresdat = new File(HIGHSCORE_FILE);
		if (!scoresdat.exists()) {
			try {
				scoresdat.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		scores = new ArrayList<Score>();

	}

	/*
	* Retorna uma lista de resultados ordenada do melhor para o pior
	*/
	public ArrayList<Score> getScores() {
		loadScoreFile();
		sort();
		return scores;
	}

	/*
	*	Lê o ficheiro scores.dat e carrega a lista no array de scores
	*/ 
	private void loadScoreFile() {
		try {
			ois = new ObjectInputStream(new FileInputStream(HIGHSCORE_FILE));
			scores = (ArrayList<Score>) ois.readObject();
		} catch (EOFException e) {
			System.out.println("first load");
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (oos != null) {
					oos.flush();
					oos.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}<commit_msg>jd - remover um warning<commit_after>package pt.iscte.lei.pi.firujo.scores;

import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collections;

public class HighScoreManager {

	// lista de scores
	private ArrayList<Score> scores;

	// ficheiro onde vamos guardar scores - é .dat para ninguem modificar e dar banhada nos resultados :D
	private static final String HIGHSCORE_FILE = "highscores.dat";

	ObjectOutputStream oos = null;
	ObjectInputStream ois = null;

	public HighScoreManager() {
		//se ainda nao existir o ficheiro (1o carregamento) ele cria
		File scoresdat = new File(HIGHSCORE_FILE);
		if (!scoresdat.exists()) {
			try {
				scoresdat.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		scores = new ArrayList<Score>();

	}

	/*
	* Retorna uma lista de resultados ordenada do melhor para o pior
	*/
	public ArrayList<Score> getScores() {
		loadScoreFile();
		sort();
		return scores;
	}

	/*
	*	Lê o ficheiro scores.dat e carrega a lista no array de scores
	*/ 
	@SuppressWarnings("unchecked")
	private void loadScoreFile() {
		try {
			ois = new ObjectInputStream(new FileInputStream(HIGHSCORE_FILE));
			scores = (ArrayList<Score>) ois.readObject();
		} catch (EOFException e) {
			System.out.println("first load");
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (oos != null) {
					oos.flush();
					oos.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
{'fraction_non_alphanumeric': 0.11400848999393572, 'fraction_numerical': 0.0006064281382656155, 'mean_word_length': 3.6994301994301995, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2138592', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1073, 'n_words': 294}