Assignment Six
This assignment is to process a large data file. The file is ncaa2009.data which contains the results of all games played in the NCAA Division I basketball tournament. Each line of the file has the form:
year:winning team name:score:losing team name:score
for example:
1945:New York University:70:Ohio State:65
When reading the file discard the two score fields.
This first part of the assignment is to write a separate public data class named TeamStats. This class should have private fields:
String teamName
int wins
int losses
ArrayList<String> yearsWonAGame
and public methods:
a constructor with a team name as the only parameter
accessors String getName(), int getWins(), int getLosses() and List<String> getYearsWonAGame()
modifiers void incrementsWins(), void incrementLosses() and void addYearWonAGame(String aYear)
String toString()
the class must also implement the Comparable<TeamStats> interface using the name field as the compare field.
This main class should have an ArrayList<TeamStats> object collect the information. As you can see from above, each line of the data file has a winning team name and a losing team name. After retrieving a team name construct a TeamStats object and add it to the ArrayList<TeamStats> object if it is not already there. If it was a winning team then increment the wins and add the year to the winning team's stats. If a losing team increment the losses. After the data file has been read use the Collections class sort method to sort the ArrayList<TeamStats> and display the results for each team on a separate line in a JTextArea in a JScrollPane in a JOptionPane. Finally create a static class to implement the Comparator<TeamStats> interface according to the number of wins for each team. If the wins are equal then use the number of losses. If the losses are equal then use the team name (the compareTo method). Use this to sort the ArrayList<TeamStats> again according to this Comparator and display the results of the teams again.
This assignment is due on Wednesday April 8th at the beginning of class. As usual there will be a quiz at that time.