An Example App: Random Guess

Pick a number from 1 to 10. Now have your opponent try to guess that number. Don’t give any hints; just say whether the guess is right or wrong. Imagine that your opponent is the computer, and it’s guessing at total random. That’s the app we’re going to build.

The interface is really simple, as in Figure 4.19. You can elaborate on the design, but for now, let’s just get to the good stuff: the local variable. Use a button to get the computer to make a guess. Two labels will tell the user what the latest computer guess was and whether it was correct.

Image

Figure 4.19 The Random Guess app in the Designer.

Figure 4.20 shows ...

Get Learning MIT App Inventor: A Hands-On Guide to Building Your Own Android Apps 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.