< previous page page_1015 next page >

Page 1015
PrintAll without first putting something into the list (by invoking ReadAll). Thus, a minimal test driver must open a data file, call ReadAll, then call PrintAll. But now the test driver is almost identical to the main driver for the entire program, the only difference being that the main driver calls SelSort after calling ReadAll. Therefore, we postpone a detailed discussion of testing until we have written the main driver.
The Driver: The third step in OOD is to design the driverthe top-level algorithm. In this program, all the driver has to do is invoke the operations of the masterFile object and the record list object.
Main                                                                                                    Level 0
Create empty list of personnel records named list
Open masterFile for input and verify success
list.ReadAll(masterFile, outOfMem)
IF outOfMem
   Halt the program
list.SelSort()
list.PrintAll()

Assumption: File masterFile contains no more than 1000 personnel records.
Module Structure Chart:
1015-01.gif
Below is the SortWithPointers program that implements our design. To run the program, we compile the source code files reclist.cpp and sortwithpointers.cpp into object code files reclist.obj and sortwithpointers.obj, then link the object code files to produce an executable file.

 
< previous page page_1015 next page >