CS 1711 Lab 5 - November 2 and 4, 1999
Classes and drivers
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.
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)
Note that it includes the class file graderec.h,
so be sure that VC++ is linked to the appropriate directory
Have a look at the class to understand what its data members
and methods are by either:
- using the helpsystem (the files are on the T:
drive) with Navigator or Explorer, or - looking at the file graderec.h
The main function of Gdrectst.cpp does
nothing. Modify the main function to test the implementation of
class graderec. To do this you should
Create a default GradeRecord and then write it to ensure
that the default values are correct.
Create a GradeRecord with assigned values and write them
to ensure accuracy.
Test the action of the methods (there are two in addition
to the output method) on data for which you can compute the results by
Test the program at least 6 times and record which values
you use for the test.
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.
When working on Assignment 3, be sure to use the development
method you have applied here.
Create a project on your M: drive called MyGradeRec.
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.
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
Modify the writeGradeInfo method so that the new
information is displayed and test it with a modified version of Mygrtst.cpp.
Next you are to add methods called setCurrInfo and
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.
Modify the writeGradeInfo method so that the result
of the new method is displayed and test it with a modified version of Mygrtst.cpp.
Finally, modify the writeGradeInfo method so that
the new information on the current year gpa, and the cumulative gpa information
is displayed appropriately.
Modify Mygrtst.cpp to test the completed methods.
End of Lab