Chapter 3. Adding Logic and Control to Your Programs
Making Programs React Intelligently
Our lives are filled with choices: “What should I wear today?”, “What should I eat for lunch?”, “What should I do Friday night?”, and so on. Many choices you make depend on the situation. For example, say you decide you want to go to the movies on Friday night. You’ll probably ask yourself a bunch of questions like “Are there any good movies playing?”, “Is there a movie starting at the right time?”, “Do I have enough money to go to the movies (and buy a $17 bag of popcorn)?”
Suppose there is a movie that’s playing at just the time you want to go. You then ask yourself a simple question: “Do I have enough money?” If the answer is yes, you’ll head out to the movie. If the answer is no, you won’t go. But on another Friday, you do have enough money, so you go to the movies. This scenario is just a simple example of how the circumstances around us affect the decisions we make.