Chapter 7: Making Decisions with Java If, Else, and Switch
Welcome to the final part of the first game. By the end of this chapter, you can say you have learned most of the basics of Java. In this chapter, we will learn more about controlling the flow of the game's execution, and we will also add the finishing touches to the Sub' Hunter game to make it playable.
In this chapter, we will cover the following topics:
- An example to help us remember how to use
if
andelse
- Using switch to make decisions
- How to combine multiple types of Java control flow options
- Making sense of screen touches
- Finishing the Sub' Hunter game
Another way we get to use expressions and the decision-making operators is with Java's if
, else
, and switch
keywords. These are just what we need to give our games clear and unambiguous instructions.