A game can accept the player whose turn it should record. The class diagram names the accepted type without selecting one particular player.
This is a complete Game definition. Player is an existing class with public integer field NumberOfTurns.
If the underlying C# feature is unfamiliar, use the lesson below while reading this example.
public class Game
{
public void RecordTurn(Player participant)
{
participant.NumberOfTurns = participant.NumberOfTurns + 1;
}
}Define a Game operation named RecordTurn
It accepts one Player input named participant
It updates that player's turn count
It returns no value
This method does not declare a stored Game field for the inputThese 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.
Game and Player.+RecordTurn(participant : Player) : void. Leave its attributes empty for this source.+NumberOfTurns : int. This is the field modified through the input reference.parameter type. Do not add a field association named participant.Compare this reference with the diagram you built in Violet. Layout may differ; the source meaning, labels, and relevant connections should agree.
Jordan and Casey can both be supplied on different calls. The class signature stays unchanged because both are Players.