A UML class diagram can describe:
At this point, translate those structural parts into C#.
Do not add methods, constructors, or properties unless the current diagram and course boundary require them.
UML:
Player
C#:
class Player
{
}
UML:
Player
--------------------------------
name : string
jerseyNumber : int
team : Team
C# can become:
class Player
{
public string name;
public int jerseyNumber;
public Team team;
}
Use the exact visibility, names, and types required by the current design.
For:
Team
-------------------------
name : string
create the corresponding Team class:
class Team
{
public string name;
}
The Team field in Player now refers to that custom type.
The class definition:
public Team team;
makes a Team reference possible.
The runtime assignment:
player1.team = team1;
connects two specific objects.
Class design and object state are related but different.
After translating a focused part of the UML:
The UML is the design reference.
The compiler tells you whether the C# source is valid.
Both are needed.