CS2134_HW8 - HOMEWORK #8 PROGRAMMING PART CS2134, Fall 07...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
HOMEWORK #8 PROGRAMMING PART CS2134, Fall 07 Due 11:59 p.m. Monday Dec 17 Hand it in in a single file called hw08.cpp or a zip called hw08.zip, via the Digital Drop Box. (Written part will be posted separately and will be due sooner.) In this assignment you'll modify the program from HW #3, adding some features to allow members to have buddies and to explore the “social network” of the club. For each Person, the program will maintain a list of buddies and a list of “potential buddies” (other members whom this member has invited to be on her buddy list.) If member x has invited member y to be a buddy and member y has invited member x, they become buddies and are added to one another’s buddy list and removed from their potential buddies lists. The collection of Persons along with their buddy lists forms a graph. The vertices are club members. There is an edge between two members if they are buddies. In the interactive phase, you’ll add options to invite buddies and to explore the graph. The Person class: Modify the Person by adding two additional data members 1. A potential buddies list: This is a list of ints representing the IDs of people this Person has invited to be buddies, but who are not buddies yet. 2. A buddies list: This is a list of map<int,Person>::iterators representing this Person’s current buddies. (You may use stl::lists for these lists.) Add any member functions that you need. Remember that Person now has dynamic data members, so you need to add the Big Three. Batch input phase: In addition to the data previously included in the members.txt file, for each member there will be a list of ID numbers of potential buddies. This list will have zero or more members and will be terminated by a zero. In the batch input phase, you may
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
assume that every ID that appears on a potential buddy list in the members.txt file is the ID of some member whose data appears in the members.txt file. Initialize buddy lists During or immediately after the batch input phase, the program should initialize each Person’s buddy list. If the ID of Person X is on Person Y’s potential buddy list and the ID of Person Y is on Person X’s potential buddy list, then X and Y become buddies. Remove Y’s ID from X’s potential buddy list. Remove X’s ID from Y’s potential buddy list. Insert an iterator into Y’s buddy list that points to Person X. Insert an iterator into X’s buddy list that points to Person Y. Note that the map of club members along with each member’s list of buddies can be viewed as an adjacency list representation of the graph. (Instead of storing the collection of vertices in a vector, we’re storing them in a map. This allows us to find members efficiently according to their ID numbers.) Changes to the interactive phase: Disable option 5 (“remove a member”). Leave it in the menu but just output “This menu option is not currently available” if the user tries to choose it. In addition to the previous menu options 1,2,3,4, and 6, the user can perform some
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/18/2008 for the course CS 2134 taught by Professor Hellerstein during the Fall '07 term at NYU Poly.

Page1 / 16

CS2134_HW8 - HOMEWORK #8 PROGRAMMING PART CS2134, Fall 07...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online