CS 1101 - A-term 10

Homework 11 - Developing a Social Networking Site

Due: Tuesday, October 12 at 5pm


Remember to follow the Expectations on Homework when preparing your solutions.

Assignment Goals


The Assignment

You are asked by a web startup to develop a social networking site. The site is meant to keep track of people and their friends. Also, several functions are necessary to manipulate and query the social network.

You do not have to write test cases for individual functions in this assignment. The last problem deals with testing.

  1. Provide a data definition for a person. Each person has a name and a list of friends (persons).

  2. Define a variable for a social network called network that will hold a list of persons (it should initially be empty).

  3. Write a function create-person that consumes a person's name and returns a new person with the given name (and no friends). The new person should also be added to the network. You may assume the named person does not already exist in the network. (Make sure your function creates only one person.)

  4. Write a function list-names that consumes nothing and produces a list of the names of all people in the network. Solve this problem using accumulator-style programming.

  5. Write a function connect-friends that consumes two persons, and makes them each a friend of the other. (A person A is a friend of person B if person A's friend list contains B and vice versa.) You may assume that the given persons are not already friends. Your function should return void.

  6. Write a function most-social that consumes nothing and returns the person with the most friends (resolve ties arbitrarily). Return "empty network" if network doesn't contain any persons. You may use the DrRacket built-in function length that determines the length of a list.

  7. Write a function remove-person that consumes the name of a person and removes the named person from the network. Of course, all occurrences of the named person should be removed from all friends lists.

  8. Construct a set of tests that demonstrate the correctness of your functions. Provide comments with your tests that explain what you are demonstrating, and label the results that will show up in the Interactions Window. Here's an example that shows how you can organize your tests in the Definitions Window, so that the graders will easily be able to see the results of your tests when they run your program:
    
    ;; show the initial contents of network
    "The network is initially empty"
    network
    
    ;; populate the network with one person...
    (define Glynis (create-person "Glynis"))
    "Here's the network with Glynis in it"
    network
    
    ;; (...etc.)
    

What to Turn In

Here is the grade sheet that the TAs will use when they grade Homework 11.

Using web-based turnin, turn in a single file containing all code and documentation for this assignment. Follow the naming conventions for file names. Please make sure both partners' names and wpi login names are listed in a comment at the top of the file.