Clearly, the director of the IUP Marching
Band has gone beserk. He has decided to create a salute to Computer
Science at this year's Homecoming game. Students from several Computer
Science courses have been enlisted to help with the festivities by forming
a gigantic "C++" made of students at mid-field for the half-time display.
Students from the two sections of COSC 310 are forming the second +, with
section 1 students forming the horizontal bar and students from section
2 forming the vertical bar.
During rehearsal for the half-time show,
Mrs. Lorsong, who is in charge of arranging the students, spent over an
hour getting the second + just the way she wanted it. But, she needed
to create a record of where each person was positioned so that the + could
be reproduced correctly. She asked each student to take out a piece
of paper and write down his/her own name. For those in the horizontal
bar, she asked that they write :L: after their names and then write then
name of the person to their left. For example, Eric Pennington
wrote
Eric Pennington:L:Yaman Roumani
because Yaman was to Eric's left.
For those in the vertical bar, Mrs. Lorsong asked that they write :F: after
their names and then write the name of the person in front of them.
For example, Jason Wable wrote
Jason Wable:F:Daniel Sterrett
because Dan was in front of Jason.
Naturally, the person at the extreme left end of the horizontal bar and
the one at the top of the vertical bar could not do this; so they did nothing.
The person in the exact center of the + filled out two pieces of paper
(one for the person on his left and one for the person in front of him).
Mrs. Lorsong carefully collected the papers and gave them to an assistant.
After rehearsal, the assistant was told to enter the name pairs into a computer file and to keep it "organized". But the assistant misunderstood, and after entering the names into a file, he sorted the file. The result is the file named mixedup.pos which you can find in the world-read area of the P drive for this course.
Your job is to create a C++ program that relies exclusively on lists (as defined in the STL file <list>) to read in the mixedup.pos file to display the names of the people in the horizontal bar in left to right order and to display the names of the people in the vertical bar in top (front) to bottom (back) order. The only arrays that are permitted in your program are arrays that can hold the characters of an individual person's name. All manipulation and rearrangement needed to form the bar lists must be done using list class member functions.
Here is a miniature example of what your program needs to do (working only with horizontal bar entries). Suppose the contents of the file was the five entries on the left; the program should produce the listing on the right
Eric Pennington:L:Yaman Roumani
James Neidich
Jeremy Jurick:L:James Neidich
Jeremy Jurick
Nathan Boland:L:Jeremy Jurick
Nathan Boland
Yaman Roumani:L:Shafquat Husain
Shafquat Husain
Shafquat Husain:L:Nathan Boland
Yaman Roumani
Eric Pennington
because James is the leftmost and Eric is the rightmost of those in this short collection.
Suggested approach: Read a line of the file and determine which of the following cases apply. If one name appears in an existing list, attach the other name, extending the list. If both names appear in existing lists, connect those lists into one list. If neither name appears in a list, form a new list with the two names. For the sample data, this would proceed as follows (only first names are shown here for the sake of compactness)
1st line: make
a new list for Eric and Yaman to form
Yaman -> Eric
2nd line: make a new list
for Jeremy and James to form James -> Jeremy
3rd line: add Nathan
to the list with Jeremy to form
James -> Jeremy -> Nathan
4th line: add Shafquat
to list with Yaman to form
Shafquat -> Yaman -> Eric
5th line: connect the
two lists to form
James -> Jeremy -> Nathan -> Shafquat -> Yaman -> Eric
Note that the -> used above is meant to show the link to the next name in a list. By the time your program finishes, it should have combined all the smaller lists into two lists, one for the names of people in the horizontal bar and one for the names of people in the vertical bar.
Hand in a printout of your program and
copy your .cpp file to the hand-in folder on the P drive, after naming
it after yourself, as in yourlastname.cpp
Hand in a printout of the output that your program produces when run on
the mixedup.pos file.