You already know that a class diagram can list methods.
Earlier, a parameterless method could appear as:
DisplayName() : voidA method that accepts a parameter can include that parameter in the method notation.
For example:
SetJerseyNumber(number : int) : voidInside the parentheses:
number : intmeans:
Read the entire method entry as:
UML:
SetJerseyNumber(number : int) : voidC#:
public void SetJerseyNumber(int number)
{
this.jerseyNumber = number;
}The notation order differs slightly.
The parameter meaning is the same.
UML:
SetAvailability(available : bool) : voidC#:
public void SetAvailability(bool available)
{
this.isAvailable = available;
}The class diagram describes the method's structure.
The C# supplies the executable implementation.
A class diagram describes the method generally:
SetJerseyNumber(number : int)It does not normally show one specific call such as:
SetJerseyNumber(7)That specific interaction belongs naturally in a sequence diagram.
SetJerseyNumber(number : int) : voidQuestion answered:
SetJerseyNumber(7)Question answered:
This mirrors the parameter/argument distinction in C#.
Later Learning Activities add methods with multiple parameters.
For now, keep the notation simple:
MethodName(parameterName : Type) : voidThe current goal is to connect:
method parameter in C#
↕
parameter notation in UML class diagram
↕
argument shown in sequence diagram