Chapter 16. Collections, Generics and Enumerations

This chapter will be part practical and part theory. First, we will code and use the Apple class and get our apple spawning ready for dinner. Afterward, we will spend a little time getting to know two new Java concepts ArrayList and enumerations (enum for short). These two new topics will give us the extra knowledge we will need to finish the game (mainly the Snake class) in the next chapter. In this chapter we will cover:

  • Add the graphics to the project
  • Code and use the Apple class
  • Java Collections, Generics, and the ArrayList class
  • The enhanced for loop

Let's go ahead with the project.

Adding the graphics

Grab the project's graphics from the download bundle; they are in the Chapter 16/drawable folder. Highlight the contents of this folder and copy them. Now right-click the drawable folder in the Android Studio solution explorer and select Paste. These files are the snake head and body segments as well as the apple. We will look closely at each of the graphics as we use them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.148.117