An airline assigns a boarding message from a passenger's age. Its rule is ordered: children younger than 5 board first, passengers younger than 18 board with a guardian, and everyone else uses regular boarding. An activity diagram makes the order of those checks visible.
| Condition considered | Message selected | When this check is reached |
|---|---|---|
| age < 5 | Early boarding | Always checked first |
| age < 18 | Board with guardian | Only after age < 5 is false |
| Otherwise | Regular boarding | Only after both conditions are false |
The second condition does not need to repeat age >= 5. Reaching it already tells you that the first test failed. In this teaching example, assume age is nonnegative; input validation is a separate responsibility.
Begin with a start node and the first decision diamond. Its Yes edge reaches the early-boarding action. Its No edge reaches the next decision, rather than running another action immediately.
The second diamond splits the remaining passengers into two groups. Once a message is selected, that path rejoins the other alternatives. A merge brings alternatives together; it does not mean that the actions on all branches execute.
Displaying the selected message happens for every passenger, so it belongs after the alternatives join. You do not need three copies of the display action. The final node comes after that shared work.
Do not connect the early-boarding action to the next age check. That connection would let the same passenger select another message after already receiving one. A completed branch bypasses the remaining tests.
string message;
if (age < 5)
{
message = "Early boarding";
}
else if (age < 18)
{
message = "Board with guardian";
}
else
{
message = "Regular boarding";
}
Console.WriteLine(message);The nested placement of the second decision on the No path represents an else if chain. The drawing uses two diamonds because there are two Boolean questions; the C# layout writes them as one readable sequence of alternatives.
Trace ages 4, 5, 17, and 18. For each passenger, name every diamond visited and the message selected. Age 4 should visit only the first diamond; age 5 reaches the second.
Then trace age 30. Confirm that the Regular boarding action reaches the display action exactly once and never passes through either of the other message actions.