#include <vector>
#include <string>
#include <iostream>
#include <windows.h>
using namespace::std;
class customer{
private:
char type;
double balance;
public:
void check_type(){
if(type=='p'){
if (balance<1000) {
balance=balance-2;}
else
if (balance<1000) {
balance=balance-5;}
}
}
};
class Transactions{
private:
char type;
double amount;
int houre;
int minute;
public:
Transactions(char t,double a,int h,int m):type(t),amount(a),houre(h),minute(m)
{}
void print()
{if (type=='w')
cout<<"-Withdrawal("<<amount<<")...AT:"<<houre<<":"<<minute<<"\n";
if (type=='d')
cout<<"-Deposition("<<amount<<")...AT:"<<houre<<":"<<minute<<"\n";
if (type=='z')
cout<<"-Zakat("<<amount<<")...AT:"<<houre<<":"<<minute<<"\n";
if (type=='s')
cout<<"-Standing Order("<<amount<<")...AT:"<<houre<<":"<<minute<<"\n";
}
};
////////////////////////////////////////////////////////////
class Standing_orders
{
private:
int day;
double amount;
string name;
public:
Standing_orders(int d,double a,string n):day(d),amount(a),name(n)
{}
int getday()
{return day;}
double getamount()
{return amount;}
string getname()
{return name;}
};
////////////////////////////////////////////////////////////
class Account
{
private:
string name;
int AccNum;
double balance;
char type;
vector<Standing_orders *> SO;
public:
vector<customer *> cust;
vector<Transactions *> Trans;
Account():AccNum(0),name(""),balance(0)
{}
Account(int n,string na, double b,char t):
name(na),AccNum(n),balance(b),type(t)
{}
//check_type
void checktype(char type,double balance ){
if(type=='p'){
if (balance<1000) {
balance=balance-2;}
else
if (balance<1000) {
balance=balance-5;}
}
cust.check_type(type,balance);
}
void addSO(int day,double amount,string name)
{SO.push_back(new Standing_orders(day,amount,name));}
void closeSO(int day,double amount)
{int i=0,m=-1;
int n=SO.size();
while ((i<n) && (m<0))
{if ((SO[i]->getday()==day) && (SO[i]->getamount()==amount))
m=i;
else i++;}
vector<Standing_orders *>::iterator p = SO.begin();
p +=i;
delete SO[i];
SO.erase(p,p+1);}
void procSO()
{int n=SO.size();
SYSTEMTIME st;
GetSystemTime(&st);
int day=st.wDay;
for (int i=0;i<n;i++)
if (SO[i]->getday()==day)
{
Trans.push_back(new Transactions('s',SO[i]->getamount(),st.wHour,st.wMinute));
balance=balance-SO[i]->getamount();}
}
void setName(string n)
{name=n;}
string getName()
{return name;}
void setNum(int n)
{AccNum=n;}
int getNum()
{return AccNum;}
void setbalance(double bal)
{balance=bal;}
double getbalance()
{return balance;}
void withdraw(double amount)
{balance=balance-amount;
}
void deposit(double amount)
{balance=balance+amount;}
double zakat()
{double z;
if (balance>=4000)
z=(balance*2.5)/100;
else
z=0;
if (z==0)
cout<<"This account dont reached the Zakat amount\n";
return z;}
void showone()
{
cout<<AccNum<<"-"<<name<<"......"<<balance<<"\n";}
void showTrans()
{int n=Trans.size();
for (int j=0;j<n;j++)
Trans[j]->print();}
};
////////////////////////////////////////////////////////////
class Bank{
private:
Account ZakatAccount;
vector<Account *> Accs;
public:
int FindAccountbyNumber(int accnum)
{int m=-1,i=0;
int n=Accs.size();
while ((i<n) && (m<0))
{if (Accs[i]->getNum()==accnum)
m=i;
else
i++;
}
return m;
}
int FindAccountbyName(string name)
{int i=0,m=-1;
int n=Accs.size();
while ((i<n) && (m<0))
{if (Accs[i]->getName()==name)
m=i;
else i++;}
return m;
}
void DisplayAllAccounts()
{int n=Accs.size();
for (int i=0;i<n;i++)
Accs[i]->showone();}
void OpenAccount()
{string name;
int accnum;
char t;
double OpeningBalance;
cout<<"Enter The number of customer to open acount for her/his\n";
cin>>accnum;
cout<<"Enter The name of customer\n";
cin>>name;
cout<<"Enter the start acount balance\n";
cin>>OpeningBalance;
cout<<"Enter account type (p/personal) OR (c/company): ";
cin>>t;
Accs.push_back(new Account(accnum,name,OpeningBalance,t));
Accs.checktype(t,OpeningBalance);
}
void CloseAccount()
{ int i;
int accnum;
char c;
string name;
cout<<"Enter number:";
cin>>accnum;
i = FindAccountbyNumber(accnum);
cout<<"Enter name:";
cin>>name;
i = FindAccountbyName(name);
if (i != -1)
//ÇÎÊÈÇÑ åá ÇáãÓÊÎã ÚáÇ íÑí ÇÛáÇÞ ÇáÓÇÈ Çã Çäå Õá ÈÇáÎØÃ
{cout<<"\nyou are going to close "<<name<<" acount\n";
cout<<"do you want to complet this procces\n";
cout<<" O or o for OK\n c or C for cancle\n" ;
cin>>c;
if ((c=='O') || (c=='o'))
{
vector<Account *>::iterator p = Accs.begin();
p +=i;
delete Accs[i];
Accs.erase(p,p+1);
}}}
void add_SO()
{int i;
int accnum;
string name,n;
// char c;
double d,a;
cout<<"Enter number:";
cin>>accnum;
i = FindAccountbyNumber(accnum);
cout<<"Enter name:";
cin>>name;
i = FindAccountbyName(name);
if (i != -1)
{cout<<"Enter the day of the month which it is paid:";
cin>>d;
cout<<"Enter the amount of the standing order:";
cin>>a;
Accs[i]->addSO(d,a,n);}
}
void deletSO()
{int i;
int accnum;
string name,n;
//char c;
double d,a;
cout<<"Enter number:";
cin>>accnum;
i = FindAccountbyNumber(accnum);
cout<<"Enter name:";
cin>>name;
i = FindAccountbyName(name);
if (i != -1)
{cout<<"Enter the amount of the standing order to be sure:";
cin>>a;
cout<<"Enter the day of the standing order to be sure:";
cin>>d;
Accs[i]->closeSO(d,a);}
}
void process_all_SO()
{int n=Accs.size();
for (int i=0;i<n;i++)
Accs[i]->procSO();
}
void Do_Zakat()
{
int i;
int accnum;
string name;
//char c;
SYSTEMTIME st;
GetSystemTime(&st);
double zakatAmount;
cout<<"Enter number:";
cin>>accnum;
i = FindAccountbyNumber(accnum);
cout<<"Enter name:";
cin>>name;
i = FindAccountbyName(name);
if (i != -1)
{
zakatAmount = Accs[i]->zakat();
Accs[i]->withdraw(zakatAmount);
ZakatAccount.deposit(zakatAmount);
Accs[i]->Trans.push_back(new Transactions('z',zakatAmount,st.wHour,st.wMinute));}
}
void Withdraw()
{
int i;
int accnum;
string name;
//char c;
SYSTEMTIME st;
GetSystemTime(&st);
double amount, Newbalance;
cout<<"Enter number:";
cin>>accnum;
i = FindAccountbyNumber(accnum);
cout<<"Enter name:";
cin>>name;
i = FindAccountbyName(name);
cout<<"Enter the amount to withdraw it:\n";
cin>>amount;
if (i != -1)
{Accs[i]->withdraw(amount);
Newbalance = Accs[i]->getbalance();
Accs[i]->Trans.push_back(new Transactions('w',amount,st.wHour,st.wMinute));
}}
void Deposit()
{int i;
int accnum;
string name;
// char c;
SYSTEMTIME st;
GetSystemTime(&st);
double amount, Newbalance;
cout<<"Enter number:";
cin>>accnum;
i=FindAccountbyNumber(accnum);
cout<<"Enter name:";
cin>>name;
i = FindAccountbyName(name);
cout<<"Enter the amount to deposit it:\n";
cin>>amount;
if (i != -1)
{Accs[i]->deposit(amount);
Newbalance = Accs[i]->getbalance();
Accs[i]->Trans.push_back(new Transactions('d',amount,st.wHour,st.wMinute));
}}
void ShowAccount()
{
int i;
int accnum;
string name;
// char c;
cout<<"Enter number:";
cin>>accnum;
i = FindAccountbyNumber(accnum);
cout<<"Enter name:";
cin>>name;
i = FindAccountbyName(name);
if (i != -1)
{Accs[i]->showone();
}}
void ShowTrans()
{
int i;
int accnum;
string name;
//char c;
cout<<"Enter number:";
cin>>accnum;
i = FindAccountbyNumber(accnum);
cout<<"Enter name:";
cin>>name;
i = FindAccountbyName(name);
if (i != -1)
{cout<<"\nALL Transactions of this account is:\n";
Accs[i]->showTrans();
}}
};
//////////////////////////////////////////////////////////
void choice()
{
cout<<"_________________\n";
cout<<"Enter a or A to add new acount\n";
cout<<"Enter w or W to withdrawal from one acount\n";
cout<<"Enter d or D to depositing to one acount\n";
cout<<"Enter c or C to close an acount\n";
cout<<"Enter o or O to add a standing order to one acount\n";
cout<<"Enter r or R to remove a standing order from one acount\n";
cout<<"Enter i or I to processing standing orders for all accounts\n";
cout<<"Enter p or P to show all transactions for one acount\n";
cout<<"Enter s or S to show all acounts\n";
cout<<"Enter h or H to show one acount\n";
cout<<"Enter z or Z to do Zakat calculation for an acount\n";
cout<<"Enter q or Q to quit the program\n";
cout<<"_________________\n";
}
//////////////////////////////////////////////////////////
main()
{
char c;
choice();
cin>>c;
Bank b;
do{
switch (c)
{case 'w':
case 'W':
b.Withdraw();
choice();
cin>>c;
break;
case 'd':
case 'D':
b.Deposit();
choice();
cin>>c;
break;
case 'a':
case 'A':
b.OpenAccount();
choice();
cin>>c;
break;
case 'o':
case 'O':
b.add_SO();
choice();
cin>>c;
break;
case 'r':
case 'R':
b.deletSO();
choice();
cin>>c;
break;
case 'i':
case 'I':
b.process_all_SO();
choice();
cin>>c;
break;
case 's':
case 'S':
b.DisplayAllAccounts();
choice();
cin>>c;
break;
case 'p':
case 'P':
b.ShowTrans();
choice();
cin>>c;
break;
case 'h':
case 'H':
b.ShowAccount();
choice();
cin>>c;
break;
case 'z':
case 'Z':
b.Do_Zakat();
choice();
cin>>c;
break;
case 'c':
case 'C':
b.CloseAccount();
choice();
cin>>c;
break;
};
}while ((c!='q') && (c!='Q'));
return 0;
}
that is the code
here is the error:
--------------------Configuration: sa - Win32 Debug--------------------
Compiling...
sa.cpp
C:\Documents and Settings\A\My Documents\sa.cpp(96) : error C2039: 'check_type' : is not a member of 'vector<class customer *,class std::allocator<class customer *> >'
Error executing cl.exe.
sa.exe - 1 error(s), 0 warning(s