Chapter 9. A Guessing Game
One of the great things about computers is that they can make decisions and take different paths through a program based on those decisions. If computer programs did the same thing every time, then they would be pretty boring. Can you imagine playing a computer game that always did the same thing? Computers make decisions all the time. When you’re playing Minecraft, the server is constantly checking to see whether any players have died or whether their health or hunger levels are low. It’s checking to see whether a creeper is about to explode or whether a villager will accept a trade offer. All of these decisions are made using the humbly named if statement. The if statement is such a useful statement that it’s available ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access