(Latest Revision: 03/24/2000)
03/22/2000 -- fixed deficiencies in
definition of NEWCLIENT
03/24/2000 -- put all examples of lists of interests in alphabetical order
03/24/2000 -- assigned responsibility for order of lists of interests
03/22/2000 -- added requirement for ordered interests in
NEWCLIENT command
Using A List of Structures: Computer Dating Service
THE ASSIGNMENT:
Your assignment is to write a simple version of a program for a
computer dating service. Each client will gives his or her
name, phone number, and a list of interests. It will be the
job of your program to maintain lists of men and women using
the service and to match up "compatible" couples.
DATA STRUCTURES:
The problem requires you to maintain two separate lists of
clients, one for men and one for women. We do not require lists
of clients to be in alphabetical order. New clients may be
added to the end of the appropriate list.
Each list element must include all the information for one
client:
- last name,
- first name,
- phone number,
- number of interests (maximum number is 10),
- list of interest strings , and
- the list position of this client's current match (0 if not
matched).
Each list of interests in the clients file is required to be in
alphabetical order. This is the responsiblity of the person
who maintains the clients file. It is a precondition of the
program that all interests lists in the client file are in
order.
You must adapt the list class given in chapter 3 of our text for
use in this program. The source code for the list class is
included in the assignment directory.
INPUT:
The input comes from two text files, called clients and
datecoms. (You must use precisely those
names.) The clients input file contains the data about
current clients:
1. Number of current clients
2. For each current client, the file contains the following
information:
Gender 1 character, M or F.
Last Name string
First Name string
Phone Number string
Number of interests integer [3-10]
List of interests 3-10 strings, words connected
with underscore, all lower case,
in ascii (alphabetical) order.
Each item is on a line by itself. Example:
2
M
Twain
Mark
667-1234
4
bait_fishing
rafting
restaurants
writing_novels
F
Millay
Edna
566-8821
3
french_restaurants
mythology
poetry
When the program starts up, it must read clients and
build initial versions of the two client lists from the
information.
The second input file datecoms contains commands to the
dating service. Each command will begin with a command word, on
a new line of input.
COMMANDS:
NEWCLIENT <gender> <last name> <first name> <phone number> <number of interests> <interests>
Example: NEWCLIENT F Jones Jennifer 223-3321 4 bridge drink food fun
The interests must appear in alphabetical order in this
command. Add the client to the appropriate list by storing the
appropriate information. Attempt to match this new client with
a member of the opposite sex. A match occurs if and when the
program finds a a previously unmatched client with three or
more of the same interests. Two interests are "the same" if
they are exactly equal as strings. (You only have to find the
first person who matches the new client. Use the fact that
interests are sorted to make the match process easier.) Make
sure you then designate both persons as matched, as described
in the section on data structures above. Print the name of the
new client, the name of his or her match, and both phone
numbers. If no match is found, print an appropriate
message.
UNMATCH <last name> <first name>
Example: UNMATCH Newman Paul
Unmatch this person with his or her current match by setting
both current match fields to zero.
PRINTMATCH
Print a list of all matched pairs. Use a nice clear readable
format.
PRINTFREE
Print the names and phone numbers of clients who are not
currently matched.
QUIT
Stop processing commands. (This is the last line of the
file.)
OUTPUT:
Send the output corresponding to the commands above to standard
output. Do appropriate labelling and delimiting: the response
to each command must be contained in a clearly marked separate
section of output, with labels printed to make clear the
meaning of each piece of output. Echo the command itself at
the beginning of each section.
After receiving the QUIT command and before terminating
execution, the program must write the contents of the two
client lists to a file called "clients.out" in a format
suitable for later use as a clients (input) file.
What To Turn In:
It will really help me a lot in sorting my mail if you use
exactly the subject lines given. (Note there are no
spaces.)
DUE DATES:
For due dates, see
the class schedule.