This is a very inelegant way of accomplishing what I want to accomplish. Curious what a better way is
<p>It works and everything, but it looks horrible. All we're given to draw data from is a text file with the data on hockey players. We then take this data and create players from it. Then make a list of these players. At no point are we given each team's amount of wins, so I'm almost wondering if this <em>is</em> the best you can do.</p>

<p>Basically, what it wants to accomplish is to find the team with the most wins. This is found by the winning goals of each player being totalled, and judging by which team they were from, counting it for that team.</p>

<p>I accomplished this by creating the list of teams as Team objects by going through all the players and finding unique team names.</p>

<p>I then went through the player list and if the player's team was equal to the current team being looked at, it would give them points for the winning goals.</p>

<p>Then, in yet another for loop, find the team with the highest amount of these goals. </p>

<p>Return this team.</p>

<p>That's a total of four for loops for one little task. It seems gross.</p>

<pre><code>    /**
     * Returns the team with the most wins
     */
    public Team getTeamWithMostWins() {
        Team teamWithMostWins = new Team();
        List&lt;Team&gt; teams = new List&lt;Team&gt;();

        if (!players.isEmpty()) {

            // Compile the List of teams
            for (int i = 0; i &lt; players.size(); i++) {
                if (!teams.contains(players.get(i).getTeam())) {
                    teams.add(new Team(players.get(i).getTeam()));
                }
            }

            // Set the wins for the teams
            for (int i = 0; i &lt; players.size(); i++) {
                String team = players.get(i).getTeam();
                int winningGoals = players.get(i).getWinningGoals();

                // Go through the teams List to set the points
                for (int j = 0; j &lt; teams.size(); j++) {
                    // If the current player's team is equal to the current team in the loop
                    if ((teams.get(j).getName()).equals(team)) {
                        teams.get(j).incrementWinsBy(winningGoals);
                    }
                }
            }

            int mostWins = teams.get(0).getWins();

            // Find the team with the most wins
            for (int i = 1; i &lt; teams.size(); i++) {
                if (teams.get(i).getWins() &gt; mostWins) {
                    teamWithMostWins = teams.get(i);
                }
            }

        }
        else {
            teamWithMostWins = null;
        }

        return teamWithMostWins;
    }
</code></pre>
