An enum gives the Wildcats a named set of role values. The class diagram should keep that type distinct from Player instances and free-form text.
These complete declarations define a PlayerRole enum and a Player field and method that use it.
public enum PlayerRole
{
Keeper,
Forward,
Defense
}
public class Player
{
public PlayerRole Role;
public void SetRole(PlayerRole role)
{
Role = role;
}
}Define PlayerRole as a named-value type
Its named values are Keeper, Forward, and Defense
Define a Player whose Role field uses PlayerRole
Its SetRole operation accepts one value of that same enum type
Do not create one Player class or instance per enum memberThese words describe the class contract, not a sequence of runtime actions. Identify the types, stored members, operation inputs and results, and relationships before choosing compartments and connectors.
Player class box and another box representing PlayerRole.<<enumeration>> and list Keeper, Forward, and Defense as named values, one per line. These are not operations.+Role : PlayerRole and operation +SetRole(role : PlayerRole) : void.field and parameter type. Do not draw a field-reference association to an imagined enum object.Compare this reference with the diagram you built in Violet. Layout may differ; the source meaning, labels, and relevant connections should agree.
Role may currently contain Forward for Jordan, but that current choice does not belong as a fixed value in the class operation signature.