CS 1711 Lab 5 - November 2 and 4, 1999
Classes and drivers

Introduction

In this lab we will work with class files and learn how to test the implementation of a class and to modify it. In both (1) and (2) below, please be sure to save your program to demonstrate to the lab instructor. Files are to be found in  T:\comp_sci\cs1711\

1. Writing a Driver

In this section you will get some practice at taking an existing class and writing a `driver' program to test its implementation.
  1. Create a project on your M: drive called Graderectest Add the file named Gdrectst.cpp , located in the lab5 directory on the T: drive (T:\comp_sci\cs1711\lab5)
  2. Note that it includes the class file graderec.h, so be sure that VC++ is linked to the appropriate directory
  3. Have a look at the class to understand what its data members and methods are by either:

  4. - using the helpsystem (the files are on the T: drive) with Navigator or Explorer, or - looking at the file graderec.h
  5. The main function of Gdrectst.cpp does nothing. Modify the main function to test the implementation of class graderec. To do this you should

2. Modifying a Class

In this section, you will modify the GradeRecord class. You will be doing this step by step, making small changes and testing them with your driver after each step before proceeding. Reliable software can be constructed only by this method.
  1. Create a project on your M: drive called MyGradeRec. You should copy your program Gdrectst.cpp and the class file graderec.h into the new project. Call them Mygrtst.cpp and mygdrec.h. You will be modifying both.
  2. First you are to add data members to store information on the current year's courses. These should be new private int data members. They will allow the current year gpa and the cumulative gpa (the current year and preceding years combined) to be stored and reported. You will have to change the constructor with new default values for the new data.
  3. Modify the writeGradeInfo method so that the new information is displayed and test it with a modified version of Mygrtst.cpp.
  4. Next you are to add methods called setCurrInfo and currGpa. The first will be similar to the updateGradeInfo method, but will also assign values to new data members. Do you still need the updateGradeInfo method? The second method will compute the GPA for the current year data. It will be similar to gpa.
  5. Modify the writeGradeInfo method so that the result of the new method is displayed and test it with a modified version of Mygrtst.cpp.
  6. Finally, modify the writeGradeInfo method so that the new information on the current year gpa, and the cumulative gpa information is displayed appropriately.
  7. Modify Mygrtst.cpp to test the completed methods.
When working on Assignment 3, be sure to use the development method you have applied here.

End of Lab