Forum Stats

  • 3,837,399 Users
  • 2,262,255 Discussions
  • 7,900,269 Comments

Discussions

How do I implement an aggregation?

EdChouaffe
EdChouaffe Member Posts: 125
edited Dec 26, 2011 1:20AM in Java Desktop Applications
Hi guys,

I was wondering how do I implement an aggregation in Java.
Here is the case:

Team has a 1 to N association to player.

First suggestion:
class Team{
      ArrayList<Player> players;
      ...
}

class Player{
...}
Second suggestion:
class Team{
      ArrayList<Player> players;
      ...
}

class Player{
    Team team
...}
My question is actually to know whether the objects of the class Player should know about the object Team that contains them.
I had a discussion about with a colleague of mine, and I really need to clear things up.
I personally tend for the first suggestion

Best regards.

Edmond

Answers

This discussion has been closed.