Methods for designing loops
The method for designing loops is to ask two questions: will it always end, and whenever it terminates, will the data meet the conditions required?
In the CATMOUSE example, the loop terminates (and the game ends) when:
- The mouse runs to the hole.
- The mouse runs into the cat.
- The cat catches the mouse.