Вы находитесь на странице: 1из 2

COSC 2P91 Assignment 3

Winter 2012/13
revised 3/13/2013
Due: Mar. 25 @ 12:00 pm (noon) (Late Date: Mar. 28).
Linked Structures
This assignment is intended to provide experience in processing linked structures and pointers.
Contact List
A contact list is a collection of information about individuals or organizations with whom the
user has contact. Typically the information on a contact includes the contacts name, address,
phone number and email address.
Write a C program to manage a contact list. The program should load the contact information
from a file called Cont act s. t xt in the working directory if one exists. If not, it should start
with an empty list. The user should then be able to perform operations on the list until s/he
decides to quit, at which point the program should write the possibly updated list to
Cont act s. t xt in the working directory (replacing the previous version, if there was one.)
The file should contain four lines for each contact representing the name, address, phone number
and email address as text strings.
The contact list should be ordered by name. Unless the list is empty, there should be a current
contact (i.e. one to be examined, changed, etc.). The program should allow the following
operations:
add add a new contact including name, address, phone number and email address. It
should not be possible to add two contacts with the same name. The added contact
becomes the current contact.
change change any or all of the name, address, phone number and/or email address of the
current contact. Note that, if the name is changed, the position of the contact in
the list may also change. Regardless, the current contact remains current.
find locate a contact in the list by name. If the name exists, this contact becomes the
current contact, if not, the current contact remains the same.
next makes the next (alphabetically) contact the current contact.
previous makes the prior (alphabetically) contact the current contact.
remove removes the current contact from the list. Cannot be done if the list is empty.
The next (alphabetically) contact becomes the current contact, unless there isnt
one in which case the previous contact becomes the current contact, unless the
list is empty.
view view the details (name, address, phone number, email address) of the current
contact.
The program should represent the contact list by a symmetrically- (doubly-) linked list of
contacts. Contacts should be dynamically allocated and freed when removed. The list should be
sorted alphabetically by name field.
The program should provide a simple user interface designed for console use. Generally one
letter commands should be used and some feedback regarding current position should be
provided.
Programming Style
The program should use good programming style and good C-style, in particular. A larger
number of simple functions is preferred over a small number of complex functions. The program
should be well documented, layout should be good and consistent and C programming
conventions should be followed.
Submission
The zip file: ht t p: / / www. cosc. br ocku. ca/ Of f er i ngs/ 2P91/ A3Fi l es. zi p contains two files
for testing & submission: Cont act s. t xt an initial contacts file to be loaded by your
application and Scr i pt . t xt a text file as generated by the UNIX scr i pt command
showing a sample session using my cont act s program. In the sample, the commands are a-
add, c-change, f -find, n-next, p-previous, r -remove and v-view and q-quit. The prompt
@name: indicates that the current contact is name. The view command displays the name,
address, phone number and email address on consecutive lines. The change command displays
the current values of each field and, if an empty line is entered, the field is not changed;
otherwise it is changed to what was entered.
The program should run on sandcastle. Start a script (scr i pt command). Run your program
using the initial contacts file: Cont act s. t xt , and follow the sequence of commands as in
Scr i pt . t xt . After you quit your program, enter cnt l - d to stop scr i pt . The script will be
created as the file t ypescr i pt .
Your submission will be in two parts: electronic and paper. The paper submission should include
the listings of all C files you have written, the updated Cont act s. t xt file as generated by
your program and the output of the scr i pt command (t ypescr i pt ).
In addition to your paper submission, you must make an electronic submission of the assignment
including the . c and executable files of your program, runnable on sandcastle. You should have
a directory for the assignment on your Z: drive. Log on to sandcastle and navigate to the
assignment directory, at the sandcastle prompt, type:
submi t 2p91
and, when prompted, enter the appropriate information using 3 as the assignment number. The
submission program will copy the entire working directory, and all subdirectories, to the marking
directory, so you should ensure that the content of the directory is what you desire to submit.
As usual, the complete paper submission should be placed in an envelope to which a completed
coversheet (ht t p: / / www. cosc. br ocku. ca/ cover page) is attached. The submission should be made to
the COSC 2P91 submission box outside J 328 in accordance with the assignment guidelines
(ht t p: / / www. cosc. br ocku. ca/ Of f er i ngs/ 2P91/ Assi gnGui de. pdf ) and not in violation of the regulations
on plagiarism (ht t p: / / www. br ocku. ca/ webcal / 2012/ under gr ad/ ar eg. ht ml #sec68,
ht t p: / / www. cosc. br ocku. ca/ about / pol i ci es/ pl agi ar i sm). Note: Assignments not including a
coversheet will not be marked.

Вам также может понравиться