Ok.. this is an assignment.. i'm not going to lie.
but i have done almost everything of it.. just need some help on the stl <vector>/ <list>
this is my code for the question..Code:#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
class customer
{
string name;
string address;
int phoneNum;
public:
customer(string inName, string inAddress, int inPhoneNum);
void display();
friend bool operator==(const customer &left, const customer &right);
};
bool operator==(const customer &left, const customer &right)
{
if ((left.name==right.name))
return true;
else
return false;
};
customer::customer(string inName, string inAddress, int inPhoneNum)
{
name = inName;
address = inAddress;
phoneNum = inPhoneNum;
}
void customer::display()
{
cout<<"Name :"<<name<<endl;
cout<<"Address:"<<address<<endl;
cout<<"Phone Number:"<<phoneNum<<endl;
}
class Account
{
int accountNumber;
double accountBalance;
int dateOpened;
vector <customer> transactions;
public:
Account(int inAccountNumber, double inAccountBalance,
int inDateOpened,vector <customer> inTransactions);
bool makeDeposit();
bool makeWithdrawal();
};
Account::Account(int inAccountNumber, double inAccountBalance, int inDateOpened,
vector <customer> inTransactions)
{
accountNumber = inAccountNumber;
accountBalance = inAccountBalance;
dateOpened = inDateOpened;
transactions = inTransactions;
}
class checkingAccount: public Account
{
private:
string chequeStyle;
double minimumBalance;
public:
checkingAccount(int inAccountNumber, double inAccountBalance,
int inDateOpened, vector <customer> inTransactions, string inChequeStyle,
double inMinimumBalance);
void display();
};
class savingsAccount: public Account
{
private:
int interestRate;
public:
savingsAccount( int inAccountNumber, double inAccountBalance,
int inDateOpened, vector <customer> inTransactions, int inInterestRate);
};
int main()
{
system("pause");
return 0;
}
A general bank Account has the following basic features. It has:
• the accountBalance. This maintains the current balance in the account and
makes it easy for us to decide when withdrawals should be disallowed;
A bank account system design class diagram
• transactions, consisting of the amount, positive or negative, which is added
to the account. A deposit is a positive transaction and a withdrawal is a
negative transaction. Transaction details are held together dynamically in a
‘linked’ structure. The most recent transaction will be the last entry added.
The amount of the transaction could be a float or a double. You choose. If
you are a ‘big’ spender you will probably use doubles! If we sum the
amounts stored in the transaction list it will equal the accountBalance;
• an accountNumber. You could get the system to do this automatically or
look to add it in yourself. Again you choose. Please explain the reason for
your choice however.
You have met 'linked structures' previously. Use the STL to manage the collection
of transactions.
// just posted the question to allow you have more understanding of it (which frankly i don't have atm)..
how to add stl to the transactions?
do i have to declare it under customer class or the account class?
pls help
and thanks in advance