public class TeamLoader
{
public static void main(String[] args)
{
String[] names = {
"Arsenal", "Aston Villa", "Birmingham", "Blackburn",
"Bolton", "Chelsea", "Derby", "Everton", "Fulham",
"Liverpool", "Man City", "Man Utd", "Middlesbrough",
"Newcastle", "Portsmouth", "Reading", "Sunderland",
"Tottenham", "West Ham", "Wigan"
};
int[] ratings = {
90, 78, 65, 81, 60, 91, 50, 74, 76, 90,
89, 91, 82, 77, 83, 59, 57, 81, 74, 54
};
TeamInfo[] teams = new TeamInfo[names.length];
for(int j = 0; j < teams.length; j++) {
teams[j] = new TeamInfo(names[j], ratings[j]);
}
Team team = new Team("a team", 100);
team.addTeams(teams);
System.out.println(team);
System.out.println("bestRated = " + team.getBestRatedTeam());
}
}
class Team extends TeamInfo
{
...
public void addTeams(TeamInfo[] newTeams)
{
for(int j = 0; j < newTeams.length; j++)
teams.add(newTeams[j]);
}