Do forever
call Display
Mouse's move
Cat's move
end
Conclusion
Methods for Designing Loops
The method for designing loops is to ask two questions:
v Will it always end?
v Whenever it terminates, will the data meet the conditions required?
Well, the loop terminates (and the game ends) when:
1. The mouse runs to the hole.
2. The mouse runs into the cat.
3. The cat catches the mouse.
The Conclusion
At the end of the program, the user must be told what happened.
call display
say who won
Programming Style and Techniques
Chapter 10. Programming Style and Techniques 93