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 and else
  • 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 ...

Get Learning Java by Building Android Games - Second 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.