Hi all.
I’m supposed to be writing a code that involves arrays of objects and I’m becoming a bit overwhelmed with a certain part of the code. I feel I might be over thinking it though, so any pointers in the right direction would be appreciated.
I’m writing a code that displays a Bank Statement. It involves two classes, one called Transaction and another called Statement. Transaction basically details the transaction itself (the amount, whether it is a withdrawal or deposit, and a note on what the transaction was for). Statement collects the data and compiles it together to display all the transactions that have been done and the end results (end balance, number of withdrawals/deposits, transaction history, etc).
My problem is with a function void EnterTransactions. It’s supposed to place the transaction input into a transaction log array, update a running balance array and adjust the Number of entries, number of deposits/withdrawal and the end balance.
I’m not sure exactly how to fill the arrays since the transactions are an object of the Transaction class? On top of that, we were provided a non-interactive driver to fill the arrays with and I’m a little lost on how to fill the arrays with it (I am use to using user input to fill the arrays.)
Right now my code is broken because of identifier issues (which I am hunting down and trying to fix) so for now I'm just looking to see if I'm even going in the right direction with filling these arrays.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
void BankStatement::EnterTransaction() //Transaction Input?
{
for (NumEntries=0; NumEntries < MaxTransactions; NumEntries++)
{
TransactionLog[NumEntries] = Transaction.Transaction(); //Not sure if this is legal.
//RunningBal[NumEntries] = ??? //Array updated for each transaction entry.
}
if(Code == 'D' || Code == 'd')
{NumDeposits++;}
else if(Code == 'W' || Code == 'w')
{NumWithdrawals++;}
else
{cout << "No transaction.";}
}
|
If there's any other part of the code I need to post, please let me know.