1 Problem Definition . Banks have Accounts and Accounts have Transactions. You can find more detail in their respective sections.
In this homework you are a programmer and your supervisors want certain features in their Bank system. Your task is to implement Transaction, Account and Bank systems that are provided you with a header file(You will not edit header files). As situation requested shiny features of the latest C++ is not available to you. Therefore, you have to be careful with your programs memory management.
2 Class Definitions 2.1 Transaction Transaction is the most basic class in this homework. Basically, it holds a certain amount and date of the Transaction.
2.2 Account The account is defined for a single user and users have their respective ids. Accounts also hold Transaction information of their user in a sorted manner.
∗ Note : The given activity array will have 12 Transaction∗
∗ Each of these Transaction∗ will represent a month from the 2019
∗ Basicaly activity [0] will represent January activity [11] will represent February activity [11] will represent March
. . .
activity [10] will represent November activity [11] will represent December
∗ activity [0] will only contain Transactions happened in January
∗ However , be careful that Transactions inside of activity [ i ] will not be in←sorted order
∗ For Example : We are certain that activity [0] is containing Transactions ←- happened in January 2019
∗ But we are not sure which of them happened f i r s t .
∗ I strongly suggest you to use a sorting algorithm while Transaction to your object . storing these ←- ∗ ( Sorting by the date , So that you can directly use them
)
∗ (You can use bubble sort )
∗
∗ @param id id of this Account in stream overload←- ∗ @param activity 2d Transaction array f i r s t layers lenght month is 12 for each ←- ∗ @param monthly activity frequency how many transactions
∗/ made in each month Account( int id, Transaction∗∗ const activity, int ∗ monthly_activity_frequency←-
) ;
/∗∗
∗ Destructor
∗
∗ Do not forget to free the space you have created ( This assignment does not ←use smart pointers )
∗/
˜Account() ;
/∗∗
∗ Copy constructor (Deep copy)
∗
∗ @param other The Account to be copied
∗/
Account( const Account& rhs) ;
/∗∗
∗ Copy constructor (Deep copy)
∗
∗ This copy constructors takes two time t elements
∗ Transactions of the old Account will be copied to new Account ∗ i f and only i f they are between these given dates ∗ Given dates will not be included .
∗
∗ @param rhs The Account to be copied
∗ @param start date Starting date for transaction to be copied . ∗ @param end date Ending date for transactions to be copied .
∗ give nullptr for pointers ∗ give 0 as users count
∗/ Bank() ;
/∗∗
∗ Constructor
∗
∗
∗ @param bankname name of this bank
∗ @param userspointer to hold users of this bank ∗ @param usercount number of users this bank has ∗/ Bank(std : : string bank_name, Account∗ const users, int user_count) ;
/∗∗
∗ Destructor
∗
∗ Do not forget to free the space you have created ( This assignment does not ←use smart pointers )
∗/ ˜Bank() ;
/∗∗
∗ Copy constructor (Deep copy)
∗
∗ @param rhs The Bank to be copied
∗/ Bank( const Bank& rhs) ;
/∗∗
∗ You should deep copy the content of the second bank
∗ Merge two banks
∗ If both banks has a user with the same id , Transactions of these users ←will be merged in to the same Account ∗ For example :
∗ Bank1 has [1 ,2] id users
∗ Bank2 has [2 ,3] id users
∗
∗ Bank1 after += operator will have [1 ,2 ,3] id users ∗ User with id 2 will have its transactions histories merged
∗
∗ Transactions with of the users with the same id should be merged and ←updated
∗ @param rhs Merged Bank ∗ @return this Bank
∗/
Bank& operator+=(const Bank& rhs) ;
/∗∗
∗ Add a new account to Bank
∗
∗ If the newly added user already exists in this Bank merge their ←-
Transactions
∗
∗ @param new acc new account to add to bank
∗ @return this Bank
∗/
Bank& operator+=(const Account& new_acc) ;
/∗∗ Indexing operator overload
∗
∗ Return the Account with the given id
∗
∗ If there is no Account with the given id return the f i r s t element
∗
∗ @param account id id of the Account
∗ @return i f given id exist in the bank return the account , else return the ←f i r s t account
∗
∗/
Account& operator [ ] ( int account_id) ;
/∗∗
∗ Stream overload .
∗ all the accounts will be between 01−01−2019 and 31−12−2019
∗ What to stream
∗ bank name”tab”number of users who are eligible for a loan”tab” total ←- balance of the bank
∗
∗ A user is safe for a loan i f and only i f that user did not negative balance for 2 or more consecutive months have any ←- ∗ For example , let ' s say our bank named as ”banana” has two users
∗
∗ User A' s balance for each month is
∗
∗ January − 0
∗ February − 0
∗ March − 100
∗ April − −20
∗ May − −30
∗ June − 40
∗ July − 60
∗ August − 0
∗ September − 0
∗ October − 0
∗ November − 0
∗ December − 0
∗ as given
∗ This user is not eligible because negative ( consecutive ) in April and May his/her balance was ←-
∗ You s t i l l have to add 150 to the total balance of the bank
∗ User B' s balance for
∗
∗ January − 0
∗ February − 0
∗ March − 100
∗ April − −20
∗ May − 40
∗ June − −30 ∗ July − 60
∗ August − 0
∗ September − 0
∗ October − 0
∗ November − 0
∗ December − 0
∗ each month is as given
∗ This user is eligible because negative balances were not consecutive ∗ You will also add 150
∗ to the total balance of the bank ∗ your output will be as
3 Extras You have to check for memory leaks in your code. Any memory leak in certain class will result in point reduction.
You can test your code for any memory leak by using valgrind. (Provided MakeFile has valgrind option)
You can also test your implementation by using transaction test.cpp, account test.cpp, bank test.cpp, and compare your results with provided corresponding example *.txt files. (Some text editors might display tab character in a different format. To look at the output in the best way use gedit in Ubuntu,
TextEdit in Mac or just open it with vi)
Note: You can test your classes with (ouputs of these runs also given to you)