|
|
|
|
|
|
|
if (strcmp(ptrList[placeCount]->lastName,
ptrList[minIndex]->lastName) < 0)
minIndex = placeCount;
// Swap ptrList[minIndex] and ptrList[passCount]
tempPtr = ptrList[minIndex];
ptrList[minIndex] = ptrList[passCount];
ptrList[passCount] = tempPtr;
}
}
//*****************************************************************
void RecordList::PrintAll()
// Precondition:
// ptrList[0..length-1] point to valid PersonnelData structs
// Postcondition:
// Contents of the structs pointed to by ptrList[0..length-1]
// have been written to standard output
{
int index; // Loop control variable
for (index = 0; index < length; index++)
{
// Invariant (prior to test):
// Contents of the structs pointed to by
// ptrList[0..index-1] have been printed
// && 0 <= index <= length
cout << ptrList[index]->llastName << ,
<< ptrList[index]->firstName << endl;
cout << ptrList[index]->address.street << endl;
cout << ptrList[index]->address.city << ,
<< ptrList[index]->address.state << endl;
cout << ptrList[index]->workHistory << endl;
cout << ptrList[index]->education << endl;
cout << ptrList[index]->payrollData << endl << endl;
}
} |
|
|
|
|
|
|
|
|
Testing: As with any C++ class, testing RecordList amounts to testing each of its member functions. To test the ReadAll function, a test driver that invokes only ReadAll would not be useful; we would also need to invoke PrintAll to check the results. Likewise, a test driver cannot invoke only |
|
|
|
|
|