Hi, i need help with this assignment, i got stuck, ASAP please :(
This assignment is to process a large data file. The file is ncaa2012.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
1945:New York University:70:Ohio State:65
When reading the file discard the year field and the two score fields.
I have created a class NCAATeamStats for you to use in this assignment. Use the link NCAATeamStats.java to download the class file.
This main class should read the data file using the Scanner class. Use the delimeter string “[:\n\r0-9]+”. Use an ArrayList<NCAATeamStats> object to 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. You should write a method
static int indexOf(String team, ArrayList<NCAATeamStats> teams);
that searches the ArrayList<NCAATeamStats> teams for a team name match and returns the index in the ArrayList of the matching NCAATeamStats object. If there is no match return -1.
After getting a team name from the file use the indexOf method to find a matching NCAATeamStats object if one exits. If it was a winning team then increment the wins. If a losing team increment the losses. If there is no match construct a NCAATeamStats object and add it to the ArrayList<NCAATeamStats> object. If it was a winning team then increment the wins. If a losing team increment the losses.
After the file is processed write a loop to interact with the user. Prompt the user for a team name using the JOptionPane.showInputDialog method. If the team name is in the ArrayList display the name, wins and losses by calling the toString method of the NCAATeamStats class.
See ArrayListMaxExample.java for hints.
Try the Java forum, instead.
I have to say I don't think much of the assignment.
And why return the integer index of the matching team? Why not instead return a reference to that actual NCAATeamStats object? (Or a null if not found, of course.)
I don't think your instructor is taking a very good Object Oriented approach here.
Just read the file one line at a time and split each line on the colons, giving you a String array. Then arr and arr[3[ will contain the names of the winning and losing teams. Presto.
Overall, I give the instructor no better than a C+ for this assignment.
|All times are GMT +1. The time now is 02:45 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.