|
CSci 270: Data Structures |
|
Fall 2004 |


|
Programming Assignment #1 |
|
The solution given here shows an example of how one might define an abstract class to represent Money amounts. The files Money.h and Money.cpp contain the class declarations and the implementation of the methods respectively. We have used mostly overloaded operators to implement the class, so that Money objects can be used in client programs similar to normal integer or double data types. We have also overloaded Boolean comparison operators and defined friend functions for input and output to/from Money data types.
Take note of the programming style of the suggested solution. Most of the guidelines from the CPP style guidelines document have been followed and you may see examples of them here.
Also note the test driver class. The main function is given in the file MoneyTestDriver.cpp This main function attempts to test all of the code paths defined by the Money.cpp/Money.h class. The test driver is an example of a file that might be created to allow for comprehensive testing of a newly defined data type for a coding project. Such a test driver can be used and rerun whenever changes are made to the Money class to give some level of assurance that no bugs have been introduced by modifications or fixes to the class.
Money.h - Header file contains declarations of the Money class methods and functionality. Contains documentation for using the class methods as well. Money.cpp - Implementation of the Money data type operations
MoneyTestDriver.cpp – An example of a test driver for the Money data type that attempts to thoroughly test all code paths of the Money class and is useful as a recheck to insure not bugs introduced when changes are made to the Money data type class. |
|
Programming Assignment #1 Suggested Solution |
Suggested Solution |
