CS 1101 - A-term 11

Homework 7 - Developing a Job Networking Site

Due: Tuesday, October 11 at 5pm


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

Assignment Goals


The Assignment

In this troubled economy, job networking sites have taken on increased importance. Each person who is a member of the site keeps a list of their contacts at other companies. This contact network can be used to find new jobs through second, third, and n-person connections.

In this assignment you will keep track of a master list of people in the job network. Each person in the network has a list of contacts who are other people in the 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 an entry. An entry consists of a person's name, the company where the person works, and the person's telephone number. Provide a data definition for a person. Each person consists of an entry and a list of contacts (persons).

  2. Define a state variable for a job 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, company, and telephone number and returns a new person with the given information (and no contacts). The new person should also be added to the job 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 job network. You may solve this problem one of two ways: either use accumulator-style programming, or use higher-order functions (i.e.map and/or filter).

  5. Write a function add-contact that consumes two persons. The function puts the second person in the first person's contact list (you may assume that the second person isn't already in the first person's contact list). Your function should return void. Clarification: you may assume that the two persons are in the network.

  6. Write a function most-contacts that consumes nothing and returns the person in the job network who has the most contacts in his/her contacts list (resolve ties arbitrarily). Return "empty network" if the job network doesn't contain any persons. You may use the DrRacket built-in function length that determines the length of a list. You should use accumulator-style programming. The accumulator keeps track of the person found so far who has the most contacts.

  7. Write a function change-phone that consumes the name of a person and a new telephone number and changes that person's telephone number to the new number. Of course, the change should also show up in all occurrences of the named person in any of the contact 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 be able to see the results of your tests when they run your program:
    
    ;; show the initial contents of job network
    "The job network is initially empty"
    network
    
    ;; populate the network with three people...
    (define Glynis (create-person "Glynis" "WPI" 5252))
    (define Adam (create-person "Adam" "Cisco" 5544))
    (define Jen (create-person "Jen" "Hood" 6924))
    "Here's the network with Glynis, Adam, and Jen in it"
    network
    
    ;;  put Adam in Glynis's contact list
    ;;        (etc.)
    
    

What to Turn In

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

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.