It's a program that is a sports league, a group of teams plays through a Schedule of Games and determine the winner.
The program runs fine to the point where the final output won't let me see the winner, it shows this instead:
The season winner(s) with 9 points: [Ljava.lang.String;@e73f9ac
I changed it to teams.length
which made the program work but it would show me the teams (i
) number instead of the string name like "Vancouver".
Thanks in advance.
}
int peak = 0;
int[] total = new int[teams.length];
for (int i=0; i<teams.length; i++){
total[i] = 2*wins[i]+ties[i];
if (total[i] > peak) peak = total[i];
System.out.println(teams[i]+" - " + wins[i] + " wins, " + losses[i] + " losses, " + ties[i] + " ties = " + total[i]);
}
System.out.println("The season winner(s) with " + peak + " points: " + teams);
for (int i=0; i<teams.length; i++){
if (peak < total[i]) peak = total[i];
}
}
static int indexOfTeam(String team, String[] teams){
for (int i=0; i<teams.length; i++)
if (team.compareTo(teams[i]) == 0) return i;
return -1;
}
}