Three Wildcats players are waiting for a training turn. Begin with the C# loop, identify what repeats, and draw the arrow that checks the condition again. Then add an early exit as a separate worked extension.
The code below uses the same soccer rule as the C# lesson. Read that lesson if the control statement is unfamiliar.
int waitingPlayers = 3;
int completedTurns = 0;
while (waitingPlayers > 0)
{
waitingPlayers = waitingPlayers - 1;
completedTurns = completedTurns + 1;
}Set waiting players to 3
Set completed turns to 0
WHILE players are waiting
Record one fewer waiting player
Record one more completed turn
Check whether players are waiting again
Continue after the loopPseudocode describes the behavior without requiring C# punctuation. Preserve the order, alternatives, and repetition when you simplify the wording. Draw the actions and questions; braces and semicolons do not become nodes.
The starting assignments become actions before the condition diamond. The two body assignments become actions on the while route. The arrow returning to the condition represents repetition; it must bypass the starting assignments.
Set waiting to 3, then to Set completed to 0, then to a decision diamond labeled Players waiting?. These starting assignments run once.while and the route out done. In this convention, while means the condition is true and done means it is false. The body contains Record one fewer waiting player, followed by Record one more completed turn.Players waiting?. It must bypass both starting assignments. Connect the done route to the final node. Put the final node outside the repeated body.Trace the diagram with 3 waiting players. Follow the return arrow after each pair of updates: the waiting count becomes 2, then 1, then 0. At 0, follow done without repeating either body action; the completed count is 3.
Sometimes the drill must stop while players are still waiting. The Boolean input trainingStopped already exists. In this model it stays fixed during one execution. A true value means the coach has stopped training; otherwise players finish all waiting turns.
The statement break; exits the nearest loop immediately, even when its condition is still true. Execution continues after that loop. Here it skips both body updates and goes to the shared completion action. This introduces the early exit needed in the Airline task.
int waitingPlayers = 3;
int completedTurns = 0;
while (waitingPlayers > 0)
{
if (trainingStopped)
{
break;
}
waitingPlayers = waitingPlayers - 1;
completedTurns = completedTurns + 1;
}
string status = "Training finished";Insert a second diamond labeled Training stopped? on the while route. Its true route goes through an action labeled break to Set status to Training finished. Its false route reaches the two updates and the normal return arrow.
The done route from Players waiting? also reaches Set status to Training finished. Both exits then reach the final node. The break action is an explicit marker for the jump in this exercise; the outgoing arrow is what carries execution outside the loop.
Trace both exits. With 3 waiting players and trainingStopped false, all three turns complete before the condition takes the done route. With the same waiting count and trainingStopped true, break leaves immediately and the completed count stays 0. Both routes reach Set status to Training finished.
Now start with 0 waiting players and trainingStopped true. The first loop condition takes done, so the training-stopped check and both updates are skipped. The shared status action still runs.