Dealing with CDs

Write a program to process a data file of CD (compact disc) information. The general format of the data file is illustrated by the following (the data was current in 1995 - a fine time in music history :).

37211 14.98 Bell_Biv_Devoe Hootie_Mack
39663 14.98 Armstrong_Louis Essential_Louis_Armstrong_The
15943 14.98 Various_Artists #1_Million_Sellers
10366 14.98 Gill_Johnny Johnny_Gill
47755 14.98 Various_Artists Club_MTV-Party_To_Go_Vol._1
14158 14.98 Big_Daddy_Kane Looks_Like_A_Job_For...
11341 14.98 P.M._Dawn Bliss_Album?_The

The first number on each line is a unique ID (identification) number for the CD. The rest of a line is the price, artist, and title, respectively, of each CD. There are no spaces in artist/title strings, an underscore is used in lieu of spaces. Spaces are used instead to separate price from artist and so on.

You're given a data file cdshop1995.txt of roughly 1,000 CDs. You're also given a class CDReader declared in cdreader.h and partially implemented in cdreader.cpp to help in reading the CD information. A test-program for this class that prints the data file is in testreader.cpp.

Start by compiling and running testreader.cpp specifying cdshop1995.txt as the data file.

Order Up

(To finish this part you will need to write code in processorder.cpp and in cdreader.cpp).

Finish the implementation of a program that could be part of an online ordering system for processing someone's CD order. The code is started in processorder.cpp where you must either fill in the body of a while loop in main or rewrite the program in some other way to make it work.

The general idea is to read a file of ids/CD-orders, where the file contains one CD-id per line representing a customer's order. For example, the file order1.txt is reproduced below.

45024
32597
53039
43203
37213
This represents the order shown below.
45024:	R.E.M., Automatic_for_the_People
32597:	Red_Hot_Chili_Peppers, what_hits!?
53039:	R.E.M., Reckoning
43203:	Nirvana, Incesticide
37213:	Abdul_Paula, Forever_Your_Girl
------
total = $75.9

You're to complete the program by writing no more than 20 lines of code in processorder.cpp. The code you write should use a CDReader object as is shown in the version started for you. You should call the function CDReader::findCD (not yet implemented) to determine the information about a CD given its id number (and whether there is a CD with the specified id number).

You'll need to implemente CDReader::findCD so that it works as specified to complete this part of the program. The skeletal version in cdreader.cpp is nearly complete.

When run, processorder.cpp should print the total number of CDs purchased and the total price of all the CDs.

Sorting CDs

Modify the code in cdreader.cpp to sort CDs as they are read in. To sort the CDs, you should find the location where the CD should be (sorted by artist first, then title), move other CDs out of the way, and place this CD in the correct slot in the vector that makes this CD with the others in sorted order.