Click here to Skip to main content
15,896,606 members

classes c# and the relationships between them

TOMT12345 asked:

Open original thread
If I have 3 classes:

1. Team
2. Player
3. ball

and each have a few types:

backetball team, football team, hokcey team.
basketball player, football player, hockey player.
basketball, football, hockey puck.

would i inlcuded these types as attributes in a class or would they have a class of there own and be inherited in to the above classes?

Also, im confused with the relationships. I know these facts:

1.A team needs at least one player and can have many players.
2.A player ccan onlyy have one team.
3.A player can handle a ball many times.
4.A ball can be handled by many players, but only one at a time.

I have the team to player relationship as composition.
I also have the player to ball relationship as aggregation as its options.

Is this correct or can it be done differently?
Tags: C#, Inheritance, Aggregation, Relationship

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900