Two Wildcats players can have the same name and jersey number while remaining two separate people. An object diagram must preserve that distinction.
This short excerpt runs inside an existing method. Player has public text field name and integer field jerseyNumber. Each new Player() creates a distinct instance.
If the underlying modeling idea is unfamiliar, use the lesson below while reading this example.
Player first = new Player();
first.name = "Alex";
first.jerseyNumber = 10;
Player second = new Player();
second.name = "Alex";
second.jerseyNumber = 10;Create a first Player instance
Store Alex as its name and 10 as its jersey number
Create a second Player instance
Store Alex as its name and 10 as its jersey number
Pause after both players have been initializedThese words fix the snapshot moment and separate instances, values, and reference targets. Follow the source to that pause before deciding how many boxes to draw and which current values belong inside them.
first : Player and second : Player. Each header identifies one instance and its type.name in a field-name area with value Alex, then jerseyNumber with value 10. Enter the text without quotation marks in Violet's separate value editor.Compare this reference with the diagram you built in Violet. Layout may differ; the source meaning, labels, and relevant connections should agree.
Point to each box while naming the creation expression that produced it. Editing the second player's jersey would change the second box only.