Purpose (do/learn, why this/why here): Give students a programmatic experience of data as they engage in advanced list manipulations including the higher order function map
.
In this lab, you will develop a Contact List database application like the one on your phone.
On this page, you will develop an Abstract Data Type to store and access contact data (name, address, phone number, etc.).
There are notes from BH here that are commented out.
There is user feedback here that is commented out.
point
abstract data type to store the coordinates of each point in a list of points. Here, we can make a contact
abstract data type to store the data for each contact in our list of contacts.point
constructor to construct a list of coordinates.point
constructor:coordinate
selectors:contact
constructor and selectors to access the name, address, and phone number for any given contact.contact with name: %name address: %address phone: %phone
contact
constructor that accepts three pieces of data as input: the contact's name, phone number, and address. name from contact
, address from contact
, or phone from contact
: Its somewhat artificial to use the constructor as the input to a selector; these images are just examples to show what the selectors should be able to do when given a contact as input. In your program, the selectors will take an item from the contact list as input and output the correct piece of that contact, like this:
This project demonstrates a style of programming called functional programming. In functional programming, the output of one function is used as the input to another function rather than storing temporary data in a variable.
contact
constructor to add
a few contacts to your contact list.
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 |
name
, address
, or phone
from a contact in your list