In this video, Doug Winnie walks through how to create three unique die values in our game, and store them as a group using an ArrayList collection. An ArrayList is defined by indicating the value type it will store, and using the clear and add methods to erase and add new values to the collection.
- [Instructor] We have a single die in our project.…Now, we need to extend it to support three.…But in addition to the dice,…we will need a way to loop through the values of the dice,…so we'll use an array list to build a collection…of all the dice we are creating for our game.…The array list is a flexible way to hold…a collection of objects of the same type.…In this case, we will create one…that will hold a collection of integers.…Let's first create the other two dice…that we'll need for our project.…These need to be scoped to the project,…so we will define these at the top.…Change our comments, so make it plural,…"Fields to hold the dice values."…We already have our first one,…so we can just add in two more,…int die2…and int die3.…
Next, we will create an array list called Dice…that will hold all the individual die values.…We will set it up at the top,…but define it with actual values later in our code.…Add a comment, "Array list to hold…"all three dice values."…We start with array list, then a pointed bracket,…
- Installing Android Studio
- Coding in Java and XML
- Getting a head start with starter templates
- Working with emulators
- Creating a project, variable, and toast
- Connecting XML widgets to code
- Adding images
- Adding game logic with conditional statements and operators
- Changing the data or design
Skill Level Beginner
1. Android Basics
Test your setup2m 56s
3. The Major Parts
4. Make an App
5. Tinkering with Your App
Next steps1m 4s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.