On this page, you will develop code for "Add Contact" and "Clear List" buttons in your contact list program.
contact
constructor.You'll want to ask the user for each piece of data (contact name, address, and phone number) separately.
ask
and answer
blocks together with script variables to request and then store each piece of user input until you are ready to report them all together using contact
.contact
constructor.ask
the user a specific question (like, "What is the contact's address?") and then report the user's answer
.
You could first build a more general helper block (yet another abstraction) to use in the other helper blocks instead of rewriting the
ask
and answer
script every time.
You can use these examples or make up your own:
name | address | phone |
---|---|---|
Betsy Anderson | 123 Main St. #4, New York, NY 10001 | 212-555-1234 |
Alphie Preston | 149 E. 16th Ave., Sunnyvale, CA 94089 | 208-555-6789 |
Gamal Abdel | 369 Center St., Boston, MA 02130 | 617-555-1098 |
ask
the user, "Enter c to clear the list, or enter anything else to cancel."hide variable
and show variable
to hide the contact list watcher until the end of each sprite's script.