Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: NCAATeamStatics

  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,901
    Thanks
    79
    Thanked 4,421 Times in 4,386 Posts
    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.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,901
    Thanks
    79
    Thanked 4,421 Times in 4,386 Posts
    I have to say I don't think much of the assignment.
    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:
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •