Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter
    Offline

    3
    ReputationRep:
    Hi all,

    I need to create a hashset of 5 football teams with 11 of it's players. I was going to create 55 of these hashset's with the player name, team, position and stats (goals scored) (which will entail 200+ lines of code all together). Is their a quicker way of doing this just adding all the player together in one team or is the the best way is to do the hashset is separately for each player?
    • Thread Starter
    Offline

    3
    ReputationRep:
    Anyone? Tips and suggestions appreciated.
    Offline

    17
    ReputationRep:
    What programming language is this for? This task seems like an object oriented task so my guess would be Java as that's what most unis teach. Assuming this is a uni or college task.
    • Thread Starter
    Offline

    3
    ReputationRep:
    This is Java, OOP. I know how to do the task, just wanted to know if their is a quicker way? Instead of writing one hashset of a player, his name and statistic and yet another hashset of the same thing and anoher all the way to 55 hashset's of player's name, team and position.

    Thank you
    Offline

    17
    ReputationRep:
    Well the solution is to use some kind of loop. I used a for loop. Here's an example I wrote.

    Here'a a GitHub gist I created to demonstrate my way of doing it.
    https://gist.github.com/anonymous/a0...63924e83d62ac8

    Hope it helps. Ask any questions if you've got any.

    Edit:
    Now just add those objects to a HashSet which I forgot to do. Haha
    Offline

    2
    ReputationRep:
    Thank you! Can you show me how to add those objects to a HashSet please?

    Thank you
    Offline

    17
    ReputationRep:
    (Original post by CompSci89)
    Thank you! Can you show me how to add those objects to a HashSet please?

    Thank you
    I regret posting my solution now. I feel like you will only c&p it.
    Offline

    2
    ReputationRep:
    Why don't you go to your tutor or reference this question from the materials given to you?
 
 
 
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    What's your favourite Christmas sweets?
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

    Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

    Quick reply
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.