CS108 Lab 6: Practice with TinyDB
The Insect Rememberer app is intended as a handy memory aid for entomology hobbyests. It uses a TinyDB to track association of common names and scientific names for insects, and is intended to allow easy addition of names to the database. To build it, you'll need to use a TinyDB. Also, it should be pre-populated with a few insect names, which will be stored in lists.
You'll need these components in Designer:
- Two buttons, "Store" and "Lookup"
- Two text boxes, named "commonName" and "scientificName"
- A TinyDB
Initialization
When the screen is initialized, if the database hasn't already been populated with the initial names, you'll need to put them in. This is the most complicated part. In general, your logic will look like this:
when Screen is initialized:
if the database isn't populated yet:
for each number i from 1 through the length of the list:
Store item scientific_names[i] under key common_names[i]
To determine if the database is already populated, you can check to see if the first key in the list of common_names is found in the database. If it's not, the database isn't populated. If it's in there, it is. There isn't a way to remove items from the database, so if it was initialized once, it will still be there.
Lookup and Store
Lookup and store are very similar. If the user clicks store, store the text from the scientificName textbox under the key from the commonName textbox. If the user clicks lookup, set the text in the scientificName box to the value the database finds when you look up the key in the commonName textbox.
Turning in the Lab
Show me when you have finished. You don't need to turn anything in on Blackboard for this lab.