A C# if/else if chain checks conditions in order.
A UML activity diagram can represent that same behavior with decision nodes connected along the false path.
Consider:
if (goals >= 3)
{
System.Console.WriteLine("Three or more goals.");
}
else if (goals == 2)
{
System.Console.WriteLine("Two goals.");
}
else if (goals == 1)
{
System.Console.WriteLine("One goal.");
}
else
{
System.Console.WriteLine("No goals.");
}The key behavior is:
The first C# condition is:
goals >= 3A diagram decision can be phrased:
Are there at least 3 goals?Conceptually:
Are there at least 3 goals?
◇
/ \
[true] [false]
| |
v v
Display three-or-more next decisionThe false path does not immediately mean the final else.
It leads to the next else if condition.
The next C# condition is:
goals == 2The activity flow becomes:
Are there at least 3 goals?
◇
/ \
[true] [false]
| |
v v
Display 3+ Are there exactly 2 goals?
◇
/ \
[true] [false]
| |
v v
Display 2 next decisionThis shows that the second question is evaluated only when the first question was false.
For:
else if (goals == 1)add another decision on the false path:
Are there exactly 1 goal?Now the logical sequence is:
goals >= 3?
├─ true → display 3+
└─ false → goals == 2?
├─ true → display 2
└─ false → goals == 1?
├─ true → display 1
└─ false → display 0The final false path represents the final else.
C# evaluates the chain in source order.
The UML model should preserve the same order.
Do not rearrange the decisions merely because another visual arrangement looks more balanced.
If the source asks:
the activity diagram should represent that same decision sequence.
Suppose:
goals = 3The first question:
Are there at least 3 goals?is true.
The diagram follows that true path.
The later decisions are not reached.
The activity diagram should not imply that the process continues through every remaining decision after selecting an outcome.
If all branches later continue with the same process, the outcome paths can rejoin.
Conceptually:
decision chain
/ | \
action action action
\ | /
continueThe exact visual layout can vary.
The meaning should be clear:
In C#:
else
{
System.Console.WriteLine("No goals.");
}there is no new Boolean expression.
Therefore the activity diagram does not need another decision node for the final else.
The final action is reached when every earlier condition was false.
An if/else if chain is sequential.
This is misleading:
start
/ | \
decision decision decisionThat picture suggests the questions can all be evaluated independently.
The actual C# behavior is:
decision 1
↓ false
decision 2
↓ false
decision 3Each later condition depends on the earlier conditions being false.
A UML activity diagram may visually contain several decision nodes.
That does not mean the source uses nested if statements.
For the current chain:
if (...)
)
{
}
else if (...)
)
{
}
else if (...)
)
{
}
else
{
}the decisions represent one ordered if/else if structure.
Nested conditional syntax is taught separately in CO-045.
For C#:
goals >= 3a useful UML question is:
Are there at least 3 goals?For:
goals == 2use:
Are there exactly 2 goals?The diagram should help a learner understand the logic, not require them to decode source syntax inside the decision node.
For every decision node, identify:
For every action, identify:
A trace for:
goals = 2should read:
At least 3? → false
Exactly 2? → true
Display "Two goals."
Skip remaining branches
Continue after chainThe UML and C# are aligned when they tell the same execution story.
An if/else if chain is modeled as:
decision
├─ true → action
└─ false → next decision
├─ true → action
└─ false → next decision or final elseThat pattern preserves the defining behavior of the C# structure: