The Wildcats lineup needs a connection to a particular player, rather than a copied description of that player.
Inside an existing method, Team has text field name and a Player-reference field captain. Player has text field name. The captain assignment stores a path to the existing player.
If the underlying modeling idea is unfamiliar, use the lesson below while reading this example.
Player casey = new Player();
casey.name = "Casey";
Team wildcats = new Team();
wildcats.name = "Wildcats";
wildcats.captain = casey;Create Casey and store Casey as the player name
Create the Wildcats team and store its name
Assign the existing Casey reference to the team captain field
Pause with the team and player connectedThese 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.
wildcats : Team and casey : Player. Leave enough room between them for a reference line.name with value Wildcats and add a field named captain. Leave the captain value area blank: an outgoing reference will identify its target.name with value Casey. Do not duplicate this Player inside the Team box.Object reference (from field) tool. Drag from the captain field entry to the casey object, so the line begins at the owning field and points to the target.Compare this reference with the diagram you built in Violet. Layout may differ; the source meaning, labels, and relevant connections should agree.
Follow captain from its owner, wildcats, to its target, casey. The Team stores a reference; the Player box holds Casey's selected state.