This project will help you show your mastery of dynamic arrays, classes, and libraries. (Note, this isn't dynamic memory in a class but a dynamic array of class objects.)
Write a checkbook balancing program. The program will read in the following information for all checks that were not cashed as of the last time the user balanced their checkbook:
the number of each check
the amount of the check
whether or not the check has yet been cashed
Use a dynamic array with a class base type for the checks.
The check class should have three member variables:
check number
check amount
whether or not the check's been cashed
And don't forget to provide accessors, mutators, and constructors as well as input and output methods.
BTW, the amount member variable will be of type Money. Just save this link to the Money class definition — you do not have to design it yourself!
(A closer look, however, reveals that it is just a class definition... The definitions for the methods seem to be missing. Bummer...)
(In fact, you are not allowed to change the design at all. You must implement it as is. If you feel additions are necessary, you can make them, but you must provide detailed comments as to why they were necessary. All of the current design must remain intact and fully implemented.)
In addition to all of the checks since the last checkbook update, your program should also read all of the user's deposits, the last balance we reported to them, and the new balance the bank reported to them. You will most likely desire a second [dynamic] array to hold all of the deposits. (A deposit is, of course, a Money type value.)
Your program should calculate and print the total for all checks, the total for all deposits, the calculated new balance, and how much this differs from the reported new balance. (Just in case: the new account balance should be the old balance plus all deposits and minus all cashed checks.)
Then display two lists of checks: those already cashed and those still not cashed. Sort each list from lowest to highest check number. (Note that this will not require you to split the checks into two arrays...)
To make the dynamic array management easier, you can ask the user how many checks and deposits they have to enter.
Hint: There are three sorts described in the 121 notes. One was even pseudocoded up quite nicely ...if you'd like to borrow it.
Hint: Your class should have its own library — just like the provided Money class is designed to have its own library. Other libraries may also be used for collections of functions.
Note: Since your check class has a member variable of the class type Money, you are using composition to build your check class.
Read this program description CAREFULLY! It is long and tedious. It is easy to miss essential details.
This assignment is (Level 4.5).
Add (Level 2) to allow the user to have their checks' information in a file or to type it in at the keyboard. You decide on the file's data format. They decide the entry method. (Hint: If done properly, this should simply add a little code to the main/application and NOT change your classes ...over-much.)
Add (Level 1.5) to make the check array [automatically] grow when it is necessary. That is, if there are 8 spots which are all full and a new check is waiting to be placed, you would perform a 're-allocation' to make, say, 16 spaces, copy the old data over, update the maximum size available, and free up the old array. (Remember that the memory doubling scheme is preferred for all array reallocations. Keeping the allocated size a power of two helps with this scheme immensely!)
Add (Level 2) to overload operators appropriately for your check class. (Maybe [], +, >>, <<, < — nice for sorting, eh? — etc.) (Note: operator= could count here, since it isn't already needed for dynamic memory management...)
Add another (Level 1) to overload operators appropriately for the provided Money class.
Add (Level 2) to use the dynamic list class pattern you developed elsewhere to fashion classes to manage your two dynamic arrays for this program.
In fact, add another (Level 2) to use the templated version from the options for that project.
(Keep in mind that if you do any part of this option, you'd be pretty much have an extra credit project to hand in, too. *bounce*)
Note: This project is adapted from ones given in textbooks by Walter Savitch.