Contact List App

All cell phones have some kind of Contacts list. In this lab, you will build a Contacts app yourself.

  1. Load this starter version of the app.
  2. Press the "Add Contact" button on the stage, and read the script to understand how it works. Each new contact is a list (item 1 is a name and item 2 should be a phone number), so the list of contacts is a list of lists.
  3. Fix the get phone block so that it works similarly to get name.
  4. Clear your contact list and add a few made-up people to make sure everything works.
  5. Dan had some thoughts on this next section that we implemented but then reverted. Here are the edits that were made and removed:
    • Write a reporter phone number of () that takes any part of a person's name as input, and reports a list of all the phone numbers of the people whose names match. You will need:
    • (instead of empty) c. map () over (), which performs a function over each item of the list.
    The problem with these unimplemented edits was that they required more complicated programming than is appropriate for this point in the curriculum. It would, of course, be nice if the program handled the case of multiple search results better than just returning the first one, and that should be addressed at a later point. --Aug 2016
  6. Write a reporter phone number of () that takes any part of a person's name as input, and reports that person's phone number, or "not found" if the name is not in the contact list. You will need:
    1. <string () contains ()>, which lets you find out whether one string (a contact's name in the list) contains another string (a name or part of a name).
    2. keep items such that <  > from (list), which filters the list for only the items that make the function true.
    3. empty {} ? predicate function, which returns true if the list is empty and false otherwise.
  7. When someone calls you, the phone company sends only the calling number to your phone, not the person's name. But if the number is in your contact list, your phone figures out the name. So you'll also want a blockname from number () that searches for a phone number and reports the contact's name.
Now Is a Good Time to Save Make sure everything works the way you want it to before going on. Then save!
  1. Our starter version of the app uses a single text string to hold a person's entire name. This is fine for displaying the name on the screen but makes it hard to display a list of all contacts sorted by last name. So we really want to keep the last name separate from the first name(s).
    1. Modify the get name block so that it asks separately for first names and for last name and then reports a list of the two answers. Check to make sure that adding a new contact does what you expect.
    2. Clear your contact list and add a few entries in the new format.
    3. Write two reporters that take a contact as input and report the name as a text string, in two different orders:
      name (display form) --> Abraham Lincoln
      name (sorting form) --> Lincoln, Abraham
    4. Save Your Work
    5. Check whether your phone number of () and name from number () blocks still work. Use your name (display form) selector to fix any problems.
You will soon make more improvements to this app, after addressing the idea of abstract data types, which you'll need when we return to the contact app.