Thread: help please.. linkedlists/classes

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    16

    Question help please.. linkedlists/classes

    hi, ive never posted here before so im hoping i can get some help with this question i got:

    im reading in a database, and its from a file which is nfl stats.. i cant figure out how to organize the data. its a list of a bunch of players and for each person it gives basic stats (height,weight,college,position,etc.)

    but then it breaks down there stats depending on what positoin they play. so quarterback could have stats for rushing and passing or rushing and fumbles, and a wide reciever would have rushing and recieving. or recieving and fumbles. or someone might have punt returns and defensive stats.. heres an example of one of them:

    # 20 Ed Reed
    Position: SS
    Height: 5-11
    Weight: 200
    Born: 09/11/1978
    College: Miami (Fla.)
    NFL Experience: 3
    Baltimore Ravens
    DEFENSIVE STATS
    Year Team G Total Tckl Ast Sacks Int Yds Avg Lg TD Pass Def
    2002 Baltimore Ravens 16 85 71.0 14 1 5 167 33.4 59 0 7
    2003 Baltimore Ravens 16 71 59.0 12 1 7 132 18.9 54 1 9
    2004 Baltimore Ravens 13 61 54.0 7 2 8 317 39.6 106 1 7
    TOTAL 45 217 184.0 33 4 20 616 30.8 106 2 23
    PUNT RETURNS
    Year Team G No FC Yards Avg Lg TD 20+
    2002 Baltimore Ravens 16 0 0 0 --- 0 0 0
    2003 Baltimore Ravens 16 5 3 33 6.6 19 0 0
    2004 Baltimore Ravens 13 0 0 0 --- 0 0 0
    TOTAL 45 5 3 33 6.6 19 0 0
    FUMBLES
    Year Team G Fum Lost Fum Forced Own Rec Opp Rec Yards Tot Rec TD
    2002 Baltimore Ravens 16 1 1 0 0 0 0 0 0
    2003 Baltimore Ravens 16 1 1 1 0 0 0 0 0
    2004 Baltimore Ravens 13 1 0 2 0 2 44 2 1
    TOTAL


    i know thats kinda hard to read.. but u can see that theres fumbles defensive stats and punt returns. and terell owns has recieving and rushing.. so how do i make classes to store all these things as im reading them in. do i have to make a different class for each stat title (i.e. rushing, recieving, fumbles, defensive stats, etc.) because they each have different stats that would need dif variables. or do i just make allllll the different kinds of stats private members of just a player class.. i dont get it if someone could help me or if u need me to explain better let me know

  2. #2
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    I think this would be a good opportunity to use a vector of vectors



    wecome to the boards
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    16
    I have no idea how to use vectors and although your probably correct and that would work, I'm leaning out of a book of data structures and this 'assignment' was around the linked list section in which you already have a firm idea of what classes are about. It is nowhere near the vector section, so is there anything I can do with linked lists and classes?

    If not, what would I have to do with vectors?

  4. #4
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    you don't need to be "near" the vector section. quite honestly you can learn to use vectors once you have the basic c/c++ syntax down.
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    16
    i get what your saying, but i think the book was saying that they want me to implement the program using linked lists (and obviously using classes) so i was going to try to do it like that, unless of course that is impossible

    is there a way to do this with linked lists or would i HAVE to do this with vectors

    if i can do it with linked lists, what am i overlooking that i would need to do as i do not understand how i would organize the data (my original question above)

    if this is impossible to do with linked lists (which my assumption would be that it is not. oitherwise this book im looking at is dumb to ask this question if i have to implement it with a data structure that they have not yet taught me.. but thats besides the point) then would vectors be my answer? and could someone please point me to the best place to learn vectors, perhaps a tutorial?

    thank you very much

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    >>is there a way to do this with linked lists

    Yes

    >>what am i overlooking that i would need to do as i do not understand how i would organize the data

    The two major options would be to have a player class that has fields for all data possible for any given player or to have a base player class involving stats that all players have in common, and then derive specialty players from there. The problem I see with the latter is that the different subcategories aren't mutually exclusive. Thus, I'd probably do the former.

    You might consider an embedded list of positional categories so a given player could play offense, defense, return punts, and kick field goals, if they were that talented. Each category could have it's own embedded statistical descirption list and an embedded list of yearly stat objects. Each yearly stat object could have a series of values corresponding to each item in the description list. Thus you'd have lists with lists with lists, etc.
    You're only born perfect.

  7. #7
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    fyi: a vector is more or less a linked list
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  8. #8
    Registered User
    Join Date
    Dec 2004
    Posts
    95
    Well, the standard library vector and list might have similar interfaces, but they're not at all the same thing in terms of behaviour:

    -> Lookup - vector supports constant-time lookup, list is linear time.
    -> Memory layout - vector is contiguous, list is not.
    -> Insertion, removal - insertion and removal from vector in the middle is linear time, constant time for list.
    -> Iterator invalidation - insertion/removal from middle for vector invalidates all iterators to the vector, doesn't for list. (IIRC).

    It's important to know that they are different - e.g. if you're doing lots of random insertions, a vector isn't efficient.

  9. #9
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    more or less, more or less
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  10. #10
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    If you don't know what a linked list is, or if you need help understanding them, go read the FAQ entry. Then, think about what it would take to create one using a class. While you're at it, search the forums. But then, you'd know this already if you'd read the announcements like you were supposed to.

    Quzah.
    Hope is the first step on the road to disappointment.

  11. #11
    Registered User
    Join Date
    Dec 2004
    Posts
    95
    Quote Originally Posted by misplaced
    more or less, more or less
    Not really.

Popular pages Recent additions subscribe to a feed