Upload
muhammad-rana-farhan
View
222
Download
0
Embed Size (px)
Citation preview
8/14/2019 Bank Program
1/9
Bank Program============================================#include
#include #include
#include #include
template
class List{
public:
List() { }
List(int s)
{ maxSize=s;used=0;
a=new type[maxSize];}
int getUsed(){return used;}
int getMaxSize(){return maxSize;}
bool isEmpty(){return used==0;}
bool isFull(){return used==maxSize;}
bool addObject(type obj)
{if(!isFull())
{a[used]=obj;
used++;return true;
}
else return false;
}
bool getObject(int index, type &obj){
if(!isEmpty()){
8/14/2019 Bank Program
2/9
if( (index>=0) && (index=0) && (index
8/14/2019 Bank Program
3/9
void setBalance(double bal){balance=bal;}
char *getTitle(){return title;}
int getAcNo(){return acNo;}double getBalance(){return balance;}
bool deposit(double amt){
if(amt>0)
{balance+=amt;
return true;}
elsereturn false;
}
bool withdraw(double amt)
{if(amt
8/14/2019 Bank Program
4/9
{
if(ls.addObject(obj))return true;
elsereturn false;
}
/*======= Search =======*/
int search(int key)
{int i=0;
Account t;ls.getObject(i,t);
while( (key!=t.getAcNo() ) && ( i
8/14/2019 Bank Program
5/9
bool debit(int acNo, double amt)
{int i=search(acNo);
if(i!=-1){
Account t;ls.getObject(i,t);if(t.withdraw(amt)){
ls.setObject(i,t);return true;
}else
return false;}
else
return false;}
/*======= Credit =======*/
bool credit(int acNo, double amt)
{int i=search(acNo);if(i!=-1){
Account t;ls.getObject(i,t);
if(t.deposit(amt)){
ls.setObject(i,t);
return true;}
elsereturn false;
}
else return false;}
/*======= Show All =======*/
void showAll()
{
8/14/2019 Bank Program
6/9
system("cls");
for(int i=0; i
8/14/2019 Bank Program
7/9
coutch;
switch(ch){
case 1:{
char title[30];int acNo;
double amt;for(int i=0; i
8/14/2019 Bank Program
8/9
cout
8/14/2019 Bank Program
9/9
case 5:{
b.showAll();break;
} // Case 5: End
case 6:{
exit(0);break;
}default:
cout