A constructor entry describes the information required to create any Player of this design. It belongs with the class operations, not among the stored attributes.
The example requires a name and a jersey number. Assume a positive jersey number; validation is outside this diagram task.
| Part | Diagram text |
|---|---|
| Private name field | - name : string |
| Private jersey field | - jerseyNumber : int |
| Public constructor | + Player(name : string, jerseyNumber : int) |
The names inside parentheses describe temporary inputs. The attribute entries describe storage on each instance. A parameter does not automatically declare a field.
Player class with the two private fields above.+ Player(name : string, jerseyNumber : int).+ GetName() : string and + GetJerseyNumber() : int for the public queries.: void to the constructor.A particular call such as new Player with Jordan and 7 supplies actual values; those values do not replace the types in the class signature.
The later C# lesson supplies the complete definition and shows the assignment from each parameter into its field.