Practice and reinforce the concepts from Lesson 6
Time needed: 30-35 minutes
Today, you're going to build TWO amazing apps that remember things! Have you ever wondered how apps remember your high score or your favorite settings? That's the magic of databases! You'll create a Score Counter that never forgets your points and a Random Name Picker for choosing who goes first in games!
Your first app will keep track of scores and remember them even when you close the app! How cool is that?
Please watch this video to see how this app works.
Visible and non-visible components that you will be using to make the app:
Sample UI | Components |
---|---|
![]() |
Layout: Vertical Arrangement Visible Components: Label Buttons Non-visible Components: TinyDB |
Note: This app needs only 1 screen.
Let's make your app smart! You'll program both visible and non-visible components.
First, let's create a place to store our score!
Initialize a global variable (name it as score) to 0. [Hint: Only 2 blocks]
:bulb: "Stuck?"
Look in the Variables drawer for the "initialize global" block. Set the name to "score" and the value to 0!
When the Press for score button is clicked, make these things happen:
:bulb: "Stuck?"
For TinyDB, use the "StoreValue" block. Set the tag to "score" and the value to your score variable!
When the Clear score button is clicked, program it to:
This is the coolest part! When users open the app:
:bulb: "Stuck?"
Use the "when Screen1.Initialize" block to make things happen when the app starts!
Time for your second app! This one picks random names - perfect for choosing teams or deciding who goes first!
Please watch this video to see how this app works.
Visible components that you will be using to make the app:
Sample UI | Components |
---|---|
![]() |
Layout: Vertical Arrangement Visible Components: Button Label List Picker |
Note: This app needs only 1 screen.
Let's make this fun name-picking app work!
Create a list of names to choose from!
Initialize a global variable (name it as names) to make a list of Teacher names.
:bulb: "Stuck?"
Use the "make a list" block from the Lists drawer. Add at least 5 teacher names like "Ms. Smith", "Mr. Johnson", etc.
When the Press for name button is clicked, program it to:
:bulb: "Stuck?"
Use the "pick a random item" block from the Lists drawer with your names variable!
Make sure your List Picker shows all the names when clicked!
:bulb: "Stuck?"
Set the ListPicker.Elements to your names variable in the Screen1.Initialize event.
Once you've finished both apps, try these super challenges:
Can you combine both apps? Make a game where:
Remember: Databases are like your app's memory - they never forget! Use this power wisely to make amazing apps that remember important information.
Great job learning about databases! Your apps now have super memory powers! :tada: