Chapter 10
Which Way Did He Go?
In This Chapter
Untangling complicated conditions
Writing cool conditional code
Intertwining your if
statements
It’s tax time again. At the moment, I’m working on Form 12432-89B:
If you’re married with fewer than three children, and your income is higher than the EIQ (Estimated Income Quota), or if you’re single and living in a non-residential area (as defined by Section 10, Part iii of the Uniform Zoning Act), and you’re either self-employed as an LLC (Limited Liability Company) or you qualify for veterans benefits, then skip Steps 3 and 4 or 4, 5, and 6, depending on your answers to Questions 2a and 3d.
This chapter has nothing as complex as Form 12432-89B, but it does deal with the potential complexity of if
statements.
Forming Bigger and Better Conditions
In Listing 9-2, the code chooses a course of action based on one call to the Random
class’s nextInt
method. That’s fine for the electronic oracle program described in Chapter 9, but what if you’re rolling a pair of dice? In Backgammon and other dice games, rolling 3 and 5 isn’t the same as rolling 4 and 4, even though the total for both rolls is 8. The next move varies, depending on whether or ...
Get Beginning Programming with Java® For Dummies®, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.