This assignment tests the concepts of Dynamic arrays Working with classes that explicitly utilize the heap Give you experience in using a test program to track down bugs in a class’s implementation...


This assignment tests the concepts of



  • Dynamic arrays

  • Working with classes that explicitly utilize the heap

  • Give you experience in using a test program to track down bugs in a class’s implementation


Program Objective


A smart bank will use a transaction log so that at any point they can replay events that led to a specific value. Our transaction log will allow forking of the logs order, this will be based on where our “current transction” points to. At any time, a transaction log will have a current (ie: active) transaction.


You will implement the provided transaction_log class, the header file is given to you with pre/post conditions that you will work off of. The data structure used will be a dynamic array that will grow as needed during the lifetime of the object.


You will want to create a robust test plan to check all posibilities. A small driver is given.


Transaction log class notes:



  1. The major difference between the authors bag class and the transaction log class is that ORDER matters

  2. Because you are dynamically allocating memory within your class, you will need to define and implement a copy constructor, an assignment operator, and a destructor.

  3. The transaction log depends on the transaction class.

    • A transaction has two main parts

      • Transaction id, a unique number of every transaction, which should automatically increment (without any work by you)

      • Transaction value, this is the amount of money ADDED (positive) or REMOVED (negative)

        • The value is yet another class, called long_decimal

          • long_decimal is a integer encoded decimal with a larger range of values than int, long, or double

            • The min value is -18,446,744,073,709,551,615.99

            • The max value is +18,446,744,073,709,551,615.99

            • Compared to long which is -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807

              • Even less if assume this long contains cents instead of dollars













  4. Copy and paste the invariant from transaction_log.h to your transaction_log.h file. Update the invariant for your implementation.

  5. Do your work in small steps. Create a stub for EVERY function in the header file that is not already implmented inline.

  6. Do not modify the transaction_log header file since your project will be compiled and graded using the original version.


Provided files:



transaction_log.h: The header and prototype of the transaction_log class. You will be implementing all of the functions that are not already defined inline. All of your implementation must go in transaction_log.cpp. Do not modify this header.



transaction(.h/.cpp): Provided class and implementation of transaction. Documention coming soon. These files should not be modified.



long_decimal(.h/.cpp): Provided class and implementation of transaction. Documention coming soon. These files should not be modified.



helpers(.h/.cpp): Provided functions that utilize the transaction logs current, next, and has_next to display the transaction log to output streams. These files should not be modified.



main.cpp: Driver of the transaction_log. A rough start to creating an awesome test driver for your code. It would be wise to build this first. You will want to add your test plan to this file, however, you do not submit this file.



Oct 10, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here