Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-16-2013, 10:00 PM   PM User | #1
adrixs3103
New to the CF scene

 
Join Date: Jan 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
adrixs3103 is an unknown quantity at this point
Exclamation NCAATeamStatics

Hi, i need help with this assignment, i got stuck, ASAP please
Assignment One




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

for example:




1945:New York University:70:Ohio State:65

1995:UCLA:92:Florida International:56




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.
adrixs3103 is offline   Reply With Quote
Old 01-16-2013, 10:04 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,248
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
NCAATeamStats.java
This forum is for JavaSCRIPT questions.

About the only thing that JAVA and JavaScript have in common are the first 4 letters of their names.

Try the Java forum, instead.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 01-16-2013, 10:13 PM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,248
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
I have to say I don't think much of the assignment.
Quote:
static int indexOf(String team, ArrayList<NCAATeamStats> teams);
UGH! Instead, you should have a class that, in turn, holds the ArrayList, and then have a method on that class that does the lookup.

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.

Also:
Quote:
Use the delimeter string “[:\n\r0-9]+”.
WHY?

Just read the file one line at a time and split each line on the colons, giving you a String array. Then arr[1] 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.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:33 PM.


Advertisement
Log in to turn off these ads.