I am coding a class project where I will have a basketball league. The league will include 3 divisions and each division will have 5 teams. Each team will have a number of players and one coach. I must have 5 seperate classes. I already have two classes called person and player and will also add coach. I think my next two classes will be division and team. My question is how should I implement these two classes? I must be able to add players and a coach to a team and add teams to a division. Should I use arrays for only 3 divisions and for the teams? I'm just a little confused on how to set everything up and how everything will interact.
I'll provide a ascii diagram of how you might implement this and a following explaination:
[ class_league ]
[ class_division ] [ class_team ] [ class_player ]
| | | |___________ |
| | |_[ class_division1 ] | | |___[ class_player1
| |_____[ class_division2 ] | | |___[ class_player2
|_________[ class_division3 ] | | |___[ class_player3
[ class_team1 ]______________| .... player up to 5
[ class_team2 ]______________|
[ class_team3 ]______________|
.... team division up to 5
There will be one class league.
There will be a base class, perhaps an ADT (i.e. pure virtual) class division and inhereted class divisionN where N is the sucessive number up to the number of divisions you desire.
There will be a base class team, also maybe ADT, team and inherited teams.
There will be a base class player and follows the same as the above description of base classes.
The point is, is classes have commonalities, these commonalities (i.e. functions and/or rules) will be implemented or specified for the base classes of the inherited classes. You'll have to figure the distinctions for each inherited class and their commonalities. Just some ideas.
Good luck, LamaBot