/*
Name: Program for Alibaba bank account, aiming to build a simple bank system using class and objects, but with multiple users input.
Author: muguangde
Date:09/22/2014-09:21AM
Description: This is a small program to simulate bank
account management. User create an account first, then
perform other operations.
*/
#include "Account.h"
/* Mutator Function for retrieving private member variable status */
int Account::getStatus()
{
return status;
}
string Account::getName()
{
return dep.getName();
}
string Account::getSsn()
{
return dep.getSsn();
}
/* Mutator Function for retrieving private member variable type */
int Account::getType()
{
return acctype;
}
/* Mutator Function for retrieving private member variable acctnum */
int Account::getAcctnum()
{
return acctnum;
}
/* Account: Deposit Function */
void Account::deposit()
{
double amt;
cout << "How much do you want to deposit" << endl;
cin >> amt;
bal += amt;
tr[ntrans++].setTrans(1,amt);
cout<<"************************************************************"<<endl;
cout << dep.getName()<<endl;
cout << "You have deposited " << amt << " and now have a balance of $" << bal << endl;
cout<<"************************************************************"<<endl;
}
/* Account: Withdrawal Function */
void Account::withdrawal()
{
double amt;
cout << "How much do you want to withdraw?" << endl;
cin >> amt;
if (amt <= bal) {
bal -= amt;
tr[ntrans++].setTrans(2,amt);
cout<<"************************************************************"<<endl;
cout << dep.getName()<<endl;
cout << "You have withdrawn " << amt << " and now have a balance of $" << bal << endl;
cout<<"************************************************************"<<endl;
}
else
cout << "Error: Insufficient Funds." << endl;
}
/* Account: Close Account Function */
void Account::closeAcct()
{
status = 0;
cout<<"************************************************************"<<endl;
cout << dep.getName()<<endl;
cout << "Your Account is now closed. "<< dep.getName()<<endl;
cout << "Here are your funds of " << bal <<endl;
cout<<"************************************************************"<<endl;
tr[ntrans++].setTrans(3,bal);
bal = 0;
}
/* Account: Inquiry Function */
void Account::inquiry()
{
cout<<"************************************************************"<<endl;
cout << dep.getName()<<endl;
cout << "Your current balance is $" << bal <<endl;
cout<<"************************************************************"<<endl;
prtTrans();
}
/* Account: Print Transaction */
void Account::prtTrans()
{
cout<<"************************************************************"<<endl;
cout << dep.getName()<<endl;
cout << "Here are your transactions: " << endl;
cout<<"************************************************************"<<endl;
for (int i = 0; i < ntrans; i++) {
cout<< i+1 <<": ";
tr[i].prt();
}
}
/* Account: Re-open */
void Account::reopen()
{
status = 1 ;
tr[ntrans++].setTrans(4,bal);
cout<<"************************************************************"<<endl;
cout << dep.getName()<<endl;
cout << "Your Accountt is now reopened." << endl;
cout<<"************************************************************"<<endl;
}
回到主页
回到目录