In this video, Doug Winnie adds scoring logic to the game to determine if the player rolled triples or doubles with the dice in the game. The logic is created using conditional statements, equality operators and logical operators to evaluate the numbers created by the random number generator.
- [Instructor] The rules of the game are that when we roll…triples, we will score points.…100 for triple ones, 200 for triple twos, and so on.…For doubles, we will score 50 points.…For anything else, we won't score anything,…but we'll want to display it a message to encourage…another roll.…Using a conditional statement with logical operators,…we can build the scoring logic for our game.…It will start with an if statement.…Open the main activity.java file for the project.…We're going to create a custom message to display…in our roll result in our conditional.…
Go down to the roll dice method.…Locate the string msg.…We're going to create a custom message to display…in our roll result in our conditional, so let's remove…the existing message that we currently display,…and we'll just define a new string.…Then, we can create our if statement.…Inside, we want to test if the three dice are equal…to each other.…We can determine that by finding if the first die…is equal to the second, and if the first die…is also equal to the third.…
- 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.