package objects;

import java.util.ArrayList;

public class OddsStat {

    int homeWin = 0;
    int draw = 0;
    int awayWin = 0;
    int gamesCount = 0;
    private ArrayList<Integer> goalScored = new ArrayList<>();


    public void addHomeWin() {
        homeWin++;
        gamesCount++;
    }

    public void addDraw() {
        draw++;
        gamesCount++;
    }

    public void addAwayWin() {
        awayWin++;
        gamesCount++;
    }

    public int getHomeWin() {
        return homeWin;
    }

    public void setHomeWin(int homeWin) {
        this.homeWin = homeWin;
    }

    public int getDraw() {
        return draw;
    }

    public void setDraw(int draw) {
        this.draw = draw;
    }

    public int getAwayWin() {
        return awayWin;
    }

    public void setAwayWin(int awayWin) {
        this.awayWin = awayWin;
    }

    public int getGamesCount() {
        return gamesCount;
    }

    public void setGamesCount(int gamesCount) {
        this.gamesCount = gamesCount;
    }

    public String getHomeWinPercent() {
        return String.format("%.2f", (homeWin / (float)gamesCount) * 100);
    }
    public String getDrawPercent() {
        return String.format("%.2f", (draw / (float)gamesCount) * 100);
    }
    public String getAwayWinPercent() {
        return String.format("%.2f" , (awayWin / (float)gamesCount)*100);
    }

    @Override
    public String toString() {
        return "(" + getHomeWinPercent() + ", " + getDrawPercent() + ", " + getAwayWinPercent() + ")";
    }

    public void addGoalsScored(int numGoals) {
        goalScored.add(numGoals);
    }

    public String getAvgGoalsScores() {
        return String.format("%.2f",goalScored.stream().mapToInt(Integer::intValue).average().orElse(-1.0d));
    }
}
