2.1.3 How to Represent Nested If Statements in an Activity Diagram

For this example we will be working with the code below.

There is first a test about the range of the Weight and if that's true the food will be eaten and given a rating. However, the person should only show their enjoyment of the food by burping if the rating is 3 or higher. If it isn't then they will be silent.


This is represented in the Activity Diagram below.

Be cautious, however, because the order of activities matters. Let's change the code for a moment as much as burping before eating doesn't make sense.

The Activity Diagram would now look like this: