Book Image

App Inventor 2 Essentials

Book Image

App Inventor 2 Essentials

Overview of this book

App Inventor 2 will take you on a journey of mobile app development. We begin by introducing you to the functionalities of App Inventor and giving you an idea about the types of apps you can develop using it. We walk you through the technical set up so you can take advantage of the interactive development environment (live testing). You will get hands-on, practical experience building three different apps using tutorials. Along the way, you will learn computer science principles as well as tips to help you prepare for the creative process of building an app from scratch. By the end of the journey, you will learn how to package an app and deploy it to app markets. App Inventor 2 Essentials prepares you to amass a resource of skills, knowledge and experience to become a mobile app developer
Table of Contents (15 chapters)
App Inventor 2 Essentials
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Chapter 7. Learning About Loops with a Raffle App

In the previous chapters, you used the if-then-else control block several times. The if then else block enables apps to make decisions. It is one of the fundamental computing concepts that is present in any programming language. There is a second fundamental programming concept—the loop, which we will explore in this chapter. A loop allows a program to repeat code. More specifically, in App Inventor, a loop will let us execute a stack of blocks multiple times.

To illustrate the concept of a loop, we will create a digital raffle App in this chapter. In case you aren't familiar with a regular (nondigital) raffle, we will explain. A raffle organizer gives participants a ticket with a number on it and puts a duplicate of that ticket in a bowl. When all the tickets have been given out (and put in the bowl), the raffle organizer then randomly picks a ticket out of the bowl (often times with a blindfold on) and announces the winning ticket number...