In this homework, you will implement a simple account management application for banking in C++. You will implement three basic classes. Each Bank class object has a name (name of the bank) attribute and may contain a group of Account objects . There is no limit in the number of Account objects that a Bank object may contain.
An Account object will contain the account information of a customer. Basic account information consists of the account id which is an integer, name of the account owner which is a string with at most 40 characters long, and current amount of money which is a double value. Also each account object will keep track of all past transactions on this account. Again there is no limit in the number of transactions.
Transaction class consists of: a TransType value which is the type of the transaction, a Money typed value, and timestamp of the transaction including the date and time in precision of seconds. Also if type of the transaction is a transfer (TRANSIN or TRANSOUT) then it should contain the account id and account owner name information of the transfer account as well.
Since transactions can be in 3 different currencies, you will use the Money value given below instead of a single double value. amount in Money structure will be multiplied by the rate to calculate the exact amount. Since rate may be different for different transactions, it will be kept as a part of each transaction. You are given the following class prototypes for your objects:
#include<time.h>
enum Exception {NEGATIVEAMOUNT, NEGATIVERATE, NOTENOUGHAMOUNT,
ACCOUNTNOTFOUND, ACCOUNTEXISTS};
enum Currency {TL,EURO,DOLAR} type;
enum TransType {OPEN,WITHDRAW,DEPOSIT,TRANSIN,TRANSOUT};
struct Money {
Currency type;
double amount;
double rate;
Money(double amnt=0.0,Currency ty=TL, double rt=1.0) {
amount=amnt; type=ty; rate=rt; }
};
class Transaction {
/* your implementation here */
public:
Transaction(TransType, Money);
Transaction(TransType, Money,int,const char []);
double operator! ();
int operator< (Transaction &);
friend ostream & operator<< (ostream &,Transaction &);
};
class Account {
/* your implementation here */
public:
Account(int,const char[],Money);
Account(int,const char[]);
Account(Account &);
int getid();
const char * getname();
double getamount();
Account & operator= (Account &);
Account & operator+ (Money);
Account & operator- (Money);
Account & transferto(Account &,Money);
Account & transferfrom(Account &,Money);
Account & operator|=(Account &);
friend ostream & operator<< (ostream &,Account &);
}
class Bank {
/* your implementation here */
public:
Bank(const char []);
Bank(Bank &);
void newAccount(int,const char[]);
void newAccount(int,const char[],Money);
Bank & operator=(Bank &);
Account &operator[](int);
Account &operator[](const char []);
void deleteAccount(int);
void deleteAccount(const char[]);
friend ostream & operator<< (ostream &,Bank &);
}
For Transaction class, member functions are described as:
For Account class, member functions are described as:
For Bank class, member functions are described as:
Output format for Transaction is given as follows:
"%d-%m-%y %H:%M"
format.
Output format for Account is given as follows:
Account id: ... Account owner: ... Current amount: ... TL Op | Time | Explanation | Amount | Rate | Effective |Tot. after ----+--------------+---------------+------------+--------+-----------+---------- Open 12-04-02 13:34 1000000TL 1 1000000 1000000 TrFr 14-04-02 10:00 Onur 123 500000TL 1 500000 1500000 Wit. 14-04-02 11:00 800000TL 1 -800000 700000
... parts will be filled by the corresponding value. Total after part will be filled by the cumulative amount so far after the transaction.
Output format for Bank is given as follows:
Bank name:... Account id| Account owner |Current amount(TL) ----------+------------------------------------------+---------------- ......Column fields are: Account id (1-10, right aligned), Account owner (12-53, left aligned), Current amount (55-70, right aligned, no decimal dot). Accounts will be listed in increasing order of account id.
You should consider all errors and raise the corresponding value from Exception data type. You should implement destructors of dynamic storage classes so that no garbage should be produced. Also your implementation should not contain any auxiliary functions or other public member functions. All other functions should be private class members.
You can use i=time(NULL);...=localtime(&i); call to get the current time of the system. See manual pages of localtime, time and strftime for details.
Submission details and examples will be given later.