Team LiB
Previous Section Next Section

Exercises

  1. Review all of the code associated with the SRS as produced in this chapter, and cite all cases where error handling could be improved.

  2. Use the test scaffold provided in the CourseCatalog class to test the ParseData and ParseData2 methods of that class against all of the following error situations in either the CourseCatalog.dat or Prerequisites.dat files (edit these files to introduce the following problems one by one, and then run the code to see what happens):

    1. The course name is missing from one of the records in CourseCatalog.dat (i.e., the record only contains two fields instead of three).

    2. The value for credits (third field in a record) in CourseCatalog.dat is a nonnumeric value, such as "X".

    3. The Prerequisites.dat file refers to a course that wasn't defined in the CourseCatalog.dat file.

    4. The Prerequisites.dat file is empty.

    5. The Prerequisites.dat file contains a record with only one field in it. Describe what happens in each case, and discuss what coding changes you'd have to make, if any, to handle each of the preceding situations "gracefully."

  3. Follow up exercise 2 by actually making the necessary changes to the CourseCatalog.cs file, and then retest. (Hint: This will involve exception handling.)


Team LiB
Previous Section Next Section