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 Java basics. In this chapter, we will learn more about controlling the flow of the game's execution and we will also put the finishing touches to the Sub' Hunter game to make it playable.
In this chapter we will learn:
- A slightly contrived example to help remember how to use
if
andelse
- Switching 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. They are just what we need for giving our games clear and unambiguous instructions.