SlideShare a Scribd company logo
1 of 52
Download to read offline
main.cpp
#include
#include
#include
#include
#include "Bank.hpp"
using namespace std;
int read_accts(Bank& bank, int max_accts)
{
int i = 0;
//ifstream infile("C:UsersSmart PCDesktopAssignment 3 (3110)myinput.txt");
ifstream infile("myinput");
string whiteSpace;
getline(infile, whiteSpace);
// check is file can be opened
if (infile)
{
// read only first max_accts accounts,
// in order to avoid overflow
for (i = 0; i> firstName;
// check is end of file reached
if (!infile.eof())
{
infile >> lastName;
infile >> ssn;
infile >> accountNumber;
infile >> accountType;
infile >> balance;
infile >> status;
infile >> transactions;
bank.addAccount(firstName, lastName, ssn, accountNumber, accountType, balance,
status);
int index = bank.findAccount(accountNumber);
Account* acc = bank.getAccount(index);
for(int i=0; i> transactionType;
infile >> amount;
if (acc)
acc->addTransaction(Transaction(transactionType, amount));
}
}
else {
break;
}
}
infile.close();
}
else {
cout << "cannot open inpout file" << endl;
}
return i;
}
*/
void menu()
{
cout << "Select one of the following:" << endl << endl;
cout << " W - Withdrawal" << endl;
cout << " D - Deposit" << endl;
cout << " N - New account" << endl;
cout << " B - Balance" << endl;
cout << " I - Account Info" << endl;
cout << " H - Account Info plus Account Transaction History" << endl;
cout << " C - Close Account (close but do not delete the account)" << endl;
cout << " R - Reopen a closed account" << endl;
cout << " X - Delete Account (close and delete the account from the database))" << endl;
cout << " Q - Quit" << endl;
}
void withdrawal(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
if (index >= 0)
{
double amount;
cout << "Enter amount to withdraw: ";
cin >> amount;
// check is there possible to withdraw
if (amount>0)
{
// check is sufficient balance at account
if (bank.getAccount(index)->makeWithdrawal(amount))
{
cout << "Withdraw is completed." << endl;
}
else {
cout << "Error. Insuffucient funds." << endl;
}
}
else {
cout << "Error. Invalid amount, needed to entyer positiove number." << endl;
}
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void deposit(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
if (index >= 0)
{
double amount;
cout << "Enter amount to deposit: ";
cin >> amount;
// check is there possible to withdraw
if (amount>0)
{
bank.getAccount(index)->makeDeposit(amount); //deposit operation
cout << "Deposit is completed." << endl;
}
else {
cout << "Error. Invalid amount, needed to entyer positiove number." << endl;
}
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void new_acct(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
if (index == -1)
{
double amount;
string firstName;
string lastName;
string SSN;
string accountType;
cout << "Enter first name: ";
cin >> firstName;
cout << "Enter last name: ";
cin >> lastName;
do
{
cout << "Enter Social Security Number: ";
cin >> SSN;
// SSN is 9 digits, check for validity
if (SSN.length() == 9)
{
break;
}
else {
cout << "Error. Invalid SSN, needed to enter 9 digits. Pleasy try again." << endl;
}
} while (true);
do
{
cout << "Enter Account type (C - Checking, S - Saving, D - CD) : ";
cin >> accountType;
// check for validity
if (accountType == "C" || accountType == "S" || accountType == "D")
{
break;
}
else {
cout << "Error. Invalid Account type. Please try again" << endl;
}
} while (true);
do
{
cout << "Enter amount to deposit: ";
cin >> amount;
// check for validity
if (amount>0)
{
break;
}
else {
cout << "Error. Invalid amount, needed to entyer positiove number." << endl;
}
} while (true);
if (bank.openAccount(firstName, lastName, SSN, requested_account, accountType,
amount))
cout << "Account is opened." << endl;
else
cout << "Error. Cannot open account." << endl;
}
else {
cout << "Error. Account number "" << requested_account << "" already exists."
<< endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void close_acct(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
Account* acc = bank.getAccount(index);
if (index >= 0)
{
if (!acc->isClosed())
{
acc->close();
cout << "Account number "" << requested_account << "" has been closed. "<<
endl;
} else {
cout << "Error. Account number "" << requested_account << "" is already
closed." << endl;
}
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void reopen_acct(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
Account* acc = bank.getAccount(index);
if (index >= 0)
{
if (acc->isClosed())
{
acc->open();
cout << "Account number "" << requested_account << "" has been reopened.
"<< endl;
} else {
cout << "Error. Account number "" << requested_account << "" is already
opened." << endl;
}
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void delete_acct(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
if (index >= 0)
{
if (bank.deleteAccount(index))
cout << "Account is closed." << endl;
else
cout << "Error. Cannot close account." << endl;
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void balance(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
Account* acc = bank.getAccount(index);
if (index >= 0)
{
acc->addTransaction(Transaction("banance"));
cout << "Balance is: " << fixed << setprecision(2) << acc->getBalance() << endl;
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void account_info(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
Account* acc = bank.getAccount(index);
if (index >= 0)
{
acc->addTransaction(Transaction("getinfo"));
if (acc->getAccountType() == "S")
cout << "Saving ";
else if (acc->getAccountType() == "C")
cout << "Checking ";
else if (acc->getAccountType() == "D")
cout << "CD ";
cout << " Account #" << acc->getAccountNumber() << endl;
cout << " Depositor info:" << endl;
cout << " First name: " << acc->getDepositor().getName().getFirstname() << endl;
cout << " Last name: " << acc->getDepositor().getName().getLastname() << endl;
cout << " SSN: " << acc->getDepositor().getSSN() << endl;
cout << " Balance is: " << fixed << setprecision(2) << acc->getBalance() << endl;
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void account_info_tr(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
Account* acc = bank.getAccount(index);
if (index >= 0)
{
acc->addTransaction(Transaction("getinfo_tr"));
if (acc->getAccountType() == "S")
cout << "Saving ";
else if (acc->getAccountType() == "C")
cout << "Checking ";
else if (acc->getAccountType() == "D")
cout << "CD ";
cout << " Account #" << acc->getAccountNumber() << endl;
cout << " Depositor info:" << endl;
cout << " First name: " << acc->getDepositor().getName().getFirstname() << endl;
cout << " Last name: " << acc->getDepositor().getName().getLastname() << endl;
cout << " SSN: " << acc->getDepositor().getSSN() << endl;
cout << " Balance is: " << fixed << setprecision(2) << acc->getBalance() << endl;
int trCount = acc->getTransactionCount();
cout << endl << "Transaction List: [" << trCount << " trsnsaction(s)]" << endl;
for(int j=0; jgetTransaction(j).getTransactionType();
cout << "t";
if (acc->getTransaction(j).getAmount()>0)
{
cout << acc->getTransaction(j).getAmount();
}
cout << endl;
}
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
/*
This function prints a table of the complete account information for every active account.
*/
void print_accts(Bank& bank)
{
ofstream outfile("myoutput.txt");
if (outfile)
{
for (int i = 0; i < bank.getAccounsNumber(); i++)
{
Account* acc = bank.getAccount(i);
outfile << acc->getDepositor().getName().getFirstname();
outfile << "t";
outfile << acc->getDepositor().getName().getLastname();
outfile << "t";
outfile << acc->getDepositor().getSSN();
outfile << "t";
outfile << acc->getAccountNumber();
outfile << "t";
// save as char
outfile << acc->getAccountType();
outfile << "t";
outfile << fixed << setprecision(2) << acc->getBalance();
outfile << "t";
outfile << fixed << setprecision(2) << (acc->isClosed() ? 0 : 1);
outfile << "t";
outfile << fixed << setprecision(2) << acc->getTransactionCount();
outfile << endl;
for(int j=0; jgetTransactionCount(); j++)
{
Transaction tr = acc->getTransaction(j);
outfile << tr.getTransactionType();
outfile << "t";
outfile << tr.getAmount();
outfile << endl;
}
}
outfile.close();
}
else {
cout << "Cannot open output file";
}
}
int main()
{
string choice;
Bank bank;
int accountsNumber = 0;
bool stop = false;
accountsNumber = read_accts(bank, MAX_NUM);
print_accts(bank);
do
{
cout << endl;
menu();
cout << "Your choice: ";
cin >> choice;
if (choice == "Q" || choice == "q")
{
stop = true;
}
else if (choice == "W" || choice == "w")
{
withdrawal(bank);
}
else if (choice == "D" || choice == "d")
{
deposit(bank);
}
else if (choice == "N" || choice == "n")
{
new_acct(bank);
}
else if (choice == "B" || choice == "b")
{
balance(bank);
}
else if (choice == "I" || choice == "i")
{
account_info(bank);
}
else if (choice == "H" || choice == "h")
{
account_info_tr(bank);
}
else if (choice == "C" || choice == "c")
{
close_acct(bank);
}
else if (choice == "R" || choice == "r")
{
reopen_acct(bank);
}
else if (choice == "X" || choice == "x")
{
delete_acct(bank);
}
else
{
cout << "Invalid choice, please try again." << endl;
}
} while (!stop);
print_accts(bank);
system("pause");
return 0;
}
Account.cpp
#include "Account.hpp"
#include "Transaction.hpp"
Account::Account(void)
{
transactionCount = 0;
capacity = 101;
transactions = new Transaction[capacity];
}
Account::~Account(void)
{
delete[] transactions;
}
Account::Account(Depositor& depositor, double balance, int accountNumber, string
accountType, int status)
{
_depositor = depositor;
_balance = balance;
_accountNumber = accountNumber;
_accountType = accountType;
_status = status;
transactionCount = 0;
capacity = 101;
transactions = new Transaction[capacity];
}
Account::Account(const Account& account)
{
_depositor = account._depositor;
_balance = account._balance;
_accountNumber = account._accountNumber;
_accountType = account._accountType;
_status = account._status;
capacity = account.capacity;
transactionCount = account.transactionCount;
transactions = new Transaction[capacity];
for(int i=0; i=capacity-1)
{
capacity = capacity * 2;
Transaction* newTransaction = new Transaction[capacity];
for(int i=0; i_balance)
{
return false;
}
else
{
addTransaction(Transaction("withdraw", amount));
_balance -= amount;
return true;
}
}
void Account::open()
{
addTransaction(Transaction("open"));
_status = 1;
}
void Account::close()
{
addTransaction(Transaction("close"));
_status = 0;
}
bool Account::isClosed()
{
return _status==0;
}
Account.hpp
#ifndef Account_hpp
#define Account_hpp
#include
#include "Depositor.hpp"
#include "Transaction.hpp"
class Account
{
Depositor _depositor;
double _balance;
int _accountNumber;
string _accountType;
int _status;
int capacity;
int transactionCount;
Transaction* transactions;
public:
Account(void);
Account(Depositor& depositor, double balance, int accountNumber, string accountType, int
status);
Account(const Account& account);
~Account(void);
void addTransaction(Transaction transaction);
int getTransactionCount();
Transaction getTransaction(int index);
void open();
void close();
bool isClosed();
double getBalance();
Depositor& getDepositor();
int getAccountNumber();
string getAccountType();
void makeDeposit(double amount);
bool makeWithdrawal(double amount);
};
#endif /* Account_hpp */
Bank.cpp
#include "Bank.hpp"
Bank::Bank(void)
{
accountsNumber = 0;
}
Bank::~Bank(void)
{
}
int Bank::getAccounsNumber()
{
return accountsNumber;
}
bool Bank::openAccount(string firstName, string lastName, string ssn, int accountNumber, string
accountType, double balance)
{
if (addAccount(firstName, lastName, ssn, accountNumber, accountType, balance, 1))
{
int index = findAccount(accountNumber);
if (index>=0)
{
_accounts[index]->open();
}
return true;
}
return false;
}
bool Bank::addAccount(string firstName, string lastName, string ssn, int accountNumber, string
accountType, double balance, int status)
{
if (accountsNumbergetAccountNumber() == accountNumber)
return i;
}
return -1;
}
int Bank::findAccountSSN(string ssn)
{
for (int i = 0; igetDepositor().getSSN() == ssn)
return i;
}
return -1;
}
Account* Bank::getAccount(int index)
{
return _accounts[index];
}
bool Bank::deleteAccount(int index)
{
if (index >= 0 && index
#define MAX_NUM 100
#include "Account.hpp"
class Bank
{
Account* _accounts[MAX_NUM];
int accountsNumber;
public:
Bank(void);
~Bank(void);
bool openAccount(string firstName, string lastName, string ssn, int accountNumber, string
accountType, double balance);
bool addAccount(string firstName, string lastName, string ssn, int accountNumber, string
accountType, double balance, int status);
int findAccount(int accountNumber);
int findAccountSSN(string ssn);
Account* getAccount(int index);
bool deleteAccount(int index);
int getAccounsNumber();
};
#endif /* Bank_hpp */
Depositor.cpp
#include "Depositor.hpp"
Depositor::Depositor(void)
{
}
Depositor::~Depositor(void)
{
}
Depositor::Depositor(const Depositor& depositor)
{
_ssn = depositor._ssn;
_name = depositor._name;
}
Depositor::Depositor(Name& name, string ssn)
{
_ssn = ssn;
_name = name;
}
Name& Depositor::getName()
{
return _name;
}
string Depositor::getSSN()
{
return _ssn;
}
Depositor.hpp
#ifndef Depositor_hpp
#define Depositor_hpp
#include
#include "Name.hpp"
class Depositor
{
string _ssn;
Name _name;
public:
Depositor(void);
Depositor(const Depositor& depositor);
Depositor(Name& name, string ssn);
~Depositor(void);
Name& getName();
string getSSN();
};
#endif /* Depositor_hpp */
Name.cpp
#include "Name.hpp"
Name::Name(void)
{
}
Name::~Name(void)
{
}
Name::Name(const Name& name)
{
_firstName = name._firstName;
_lastName = name._lastName;
}
Name::Name(string firstName, string lastName)
{
_firstName = firstName;
_lastName = lastName;
}
string Name::getFirstname()
{
return _firstName;
}
string Name::getLastname()
{
return _lastName;
}
Name.hpp
#ifndef Name_hpp
#define Name_hpp
#include
#include
using namespace std;
class Name
{
string _firstName;
string _lastName;
public:
Name(void);
Name(const Name& name);
Name(string firstName, string lastName);
~Name(void);
string getFirstname();
string getLastname();
};
#endif /* Name_hpp */
Transaction.cpp
#include "Transaction.hpp"
Transaction::Transaction()
{
}
Transaction::Transaction(string transactionType, double amount)
{
_transactionType = transactionType;
_amount = amount;
}
Transaction::Transaction(string transactionType)
{
_transactionType = transactionType;
_amount = 0.0;
}
Transaction::Transaction(const Transaction& transaction)
{
_transactionType = transaction._transactionType;
_amount = transaction._amount;
}
Transaction::~Transaction(void)
{
}
string Transaction::getTransactionType()
{
return _transactionType;
}
double Transaction::getAmount()
{
return _amount;
}
Transaction.hpp
#include "Transaction.hpp"
Transaction::Transaction()
{
}
Transaction::Transaction(string transactionType, double amount)
{
_transactionType = transactionType;
_amount = amount;
}
Transaction::Transaction(string transactionType)
{
_transactionType = transactionType;
_amount = 0.0;
}
Transaction::Transaction(const Transaction& transaction)
{
_transactionType = transaction._transactionType;
_amount = transaction._amount;
}
Transaction::~Transaction(void)
{
}
string Transaction::getTransactionType()
{
return _transactionType;
}
double Transaction::getAmount()
{
return _amount;
}
Solution
main.cpp
#include
#include
#include
#include
#include "Bank.hpp"
using namespace std;
int read_accts(Bank& bank, int max_accts)
{
int i = 0;
//ifstream infile("C:UsersSmart PCDesktopAssignment 3 (3110)myinput.txt");
ifstream infile("myinput");
string whiteSpace;
getline(infile, whiteSpace);
// check is file can be opened
if (infile)
{
// read only first max_accts accounts,
// in order to avoid overflow
for (i = 0; i> firstName;
// check is end of file reached
if (!infile.eof())
{
infile >> lastName;
infile >> ssn;
infile >> accountNumber;
infile >> accountType;
infile >> balance;
infile >> status;
infile >> transactions;
bank.addAccount(firstName, lastName, ssn, accountNumber, accountType, balance,
status);
int index = bank.findAccount(accountNumber);
Account* acc = bank.getAccount(index);
for(int i=0; i> transactionType;
infile >> amount;
if (acc)
acc->addTransaction(Transaction(transactionType, amount));
}
}
else {
break;
}
}
infile.close();
}
else {
cout << "cannot open inpout file" << endl;
}
return i;
}
*/
void menu()
{
cout << "Select one of the following:" << endl << endl;
cout << " W - Withdrawal" << endl;
cout << " D - Deposit" << endl;
cout << " N - New account" << endl;
cout << " B - Balance" << endl;
cout << " I - Account Info" << endl;
cout << " H - Account Info plus Account Transaction History" << endl;
cout << " C - Close Account (close but do not delete the account)" << endl;
cout << " R - Reopen a closed account" << endl;
cout << " X - Delete Account (close and delete the account from the database))" << endl;
cout << " Q - Quit" << endl;
}
void withdrawal(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
if (index >= 0)
{
double amount;
cout << "Enter amount to withdraw: ";
cin >> amount;
// check is there possible to withdraw
if (amount>0)
{
// check is sufficient balance at account
if (bank.getAccount(index)->makeWithdrawal(amount))
{
cout << "Withdraw is completed." << endl;
}
else {
cout << "Error. Insuffucient funds." << endl;
}
}
else {
cout << "Error. Invalid amount, needed to entyer positiove number." << endl;
}
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void deposit(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
if (index >= 0)
{
double amount;
cout << "Enter amount to deposit: ";
cin >> amount;
// check is there possible to withdraw
if (amount>0)
{
bank.getAccount(index)->makeDeposit(amount); //deposit operation
cout << "Deposit is completed." << endl;
}
else {
cout << "Error. Invalid amount, needed to entyer positiove number." << endl;
}
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void new_acct(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
if (index == -1)
{
double amount;
string firstName;
string lastName;
string SSN;
string accountType;
cout << "Enter first name: ";
cin >> firstName;
cout << "Enter last name: ";
cin >> lastName;
do
{
cout << "Enter Social Security Number: ";
cin >> SSN;
// SSN is 9 digits, check for validity
if (SSN.length() == 9)
{
break;
}
else {
cout << "Error. Invalid SSN, needed to enter 9 digits. Pleasy try again." << endl;
}
} while (true);
do
{
cout << "Enter Account type (C - Checking, S - Saving, D - CD) : ";
cin >> accountType;
// check for validity
if (accountType == "C" || accountType == "S" || accountType == "D")
{
break;
}
else {
cout << "Error. Invalid Account type. Please try again" << endl;
}
} while (true);
do
{
cout << "Enter amount to deposit: ";
cin >> amount;
// check for validity
if (amount>0)
{
break;
}
else {
cout << "Error. Invalid amount, needed to entyer positiove number." << endl;
}
} while (true);
if (bank.openAccount(firstName, lastName, SSN, requested_account, accountType,
amount))
cout << "Account is opened." << endl;
else
cout << "Error. Cannot open account." << endl;
}
else {
cout << "Error. Account number "" << requested_account << "" already exists."
<< endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void close_acct(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
Account* acc = bank.getAccount(index);
if (index >= 0)
{
if (!acc->isClosed())
{
acc->close();
cout << "Account number "" << requested_account << "" has been closed. "<<
endl;
} else {
cout << "Error. Account number "" << requested_account << "" is already
closed." << endl;
}
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void reopen_acct(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
Account* acc = bank.getAccount(index);
if (index >= 0)
{
if (acc->isClosed())
{
acc->open();
cout << "Account number "" << requested_account << "" has been reopened.
"<< endl;
} else {
cout << "Error. Account number "" << requested_account << "" is already
opened." << endl;
}
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void delete_acct(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
if (index >= 0)
{
if (bank.deleteAccount(index))
cout << "Account is closed." << endl;
else
cout << "Error. Cannot close account." << endl;
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void balance(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
Account* acc = bank.getAccount(index);
if (index >= 0)
{
acc->addTransaction(Transaction("banance"));
cout << "Balance is: " << fixed << setprecision(2) << acc->getBalance() << endl;
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void account_info(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
Account* acc = bank.getAccount(index);
if (index >= 0)
{
acc->addTransaction(Transaction("getinfo"));
if (acc->getAccountType() == "S")
cout << "Saving ";
else if (acc->getAccountType() == "C")
cout << "Checking ";
else if (acc->getAccountType() == "D")
cout << "CD ";
cout << " Account #" << acc->getAccountNumber() << endl;
cout << " Depositor info:" << endl;
cout << " First name: " << acc->getDepositor().getName().getFirstname() << endl;
cout << " Last name: " << acc->getDepositor().getName().getLastname() << endl;
cout << " SSN: " << acc->getDepositor().getSSN() << endl;
cout << " Balance is: " << fixed << setprecision(2) << acc->getBalance() << endl;
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
void account_info_tr(Bank& bank)
{
int index, requested_account;
//prompt for account number
cout << endl << "Enter the account number: ";
cin >> requested_account;
// account #0 is not valid
if (requested_account != 0)
{
index = bank.findAccount(requested_account);
Account* acc = bank.getAccount(index);
if (index >= 0)
{
acc->addTransaction(Transaction("getinfo_tr"));
if (acc->getAccountType() == "S")
cout << "Saving ";
else if (acc->getAccountType() == "C")
cout << "Checking ";
else if (acc->getAccountType() == "D")
cout << "CD ";
cout << " Account #" << acc->getAccountNumber() << endl;
cout << " Depositor info:" << endl;
cout << " First name: " << acc->getDepositor().getName().getFirstname() << endl;
cout << " Last name: " << acc->getDepositor().getName().getLastname() << endl;
cout << " SSN: " << acc->getDepositor().getSSN() << endl;
cout << " Balance is: " << fixed << setprecision(2) << acc->getBalance() << endl;
int trCount = acc->getTransactionCount();
cout << endl << "Transaction List: [" << trCount << " trsnsaction(s)]" << endl;
for(int j=0; jgetTransaction(j).getTransactionType();
cout << "t";
if (acc->getTransaction(j).getAmount()>0)
{
cout << acc->getTransaction(j).getAmount();
}
cout << endl;
}
}
else {
cout << "Error. Account number "" << requested_account << "" is not found." <<
endl;
}
}
else {
cout << "Error. Invalid account number." << endl;
}
}
/*
This function prints a table of the complete account information for every active account.
*/
void print_accts(Bank& bank)
{
ofstream outfile("myoutput.txt");
if (outfile)
{
for (int i = 0; i < bank.getAccounsNumber(); i++)
{
Account* acc = bank.getAccount(i);
outfile << acc->getDepositor().getName().getFirstname();
outfile << "t";
outfile << acc->getDepositor().getName().getLastname();
outfile << "t";
outfile << acc->getDepositor().getSSN();
outfile << "t";
outfile << acc->getAccountNumber();
outfile << "t";
// save as char
outfile << acc->getAccountType();
outfile << "t";
outfile << fixed << setprecision(2) << acc->getBalance();
outfile << "t";
outfile << fixed << setprecision(2) << (acc->isClosed() ? 0 : 1);
outfile << "t";
outfile << fixed << setprecision(2) << acc->getTransactionCount();
outfile << endl;
for(int j=0; jgetTransactionCount(); j++)
{
Transaction tr = acc->getTransaction(j);
outfile << tr.getTransactionType();
outfile << "t";
outfile << tr.getAmount();
outfile << endl;
}
}
outfile.close();
}
else {
cout << "Cannot open output file";
}
}
int main()
{
string choice;
Bank bank;
int accountsNumber = 0;
bool stop = false;
accountsNumber = read_accts(bank, MAX_NUM);
print_accts(bank);
do
{
cout << endl;
menu();
cout << "Your choice: ";
cin >> choice;
if (choice == "Q" || choice == "q")
{
stop = true;
}
else if (choice == "W" || choice == "w")
{
withdrawal(bank);
}
else if (choice == "D" || choice == "d")
{
deposit(bank);
}
else if (choice == "N" || choice == "n")
{
new_acct(bank);
}
else if (choice == "B" || choice == "b")
{
balance(bank);
}
else if (choice == "I" || choice == "i")
{
account_info(bank);
}
else if (choice == "H" || choice == "h")
{
account_info_tr(bank);
}
else if (choice == "C" || choice == "c")
{
close_acct(bank);
}
else if (choice == "R" || choice == "r")
{
reopen_acct(bank);
}
else if (choice == "X" || choice == "x")
{
delete_acct(bank);
}
else
{
cout << "Invalid choice, please try again." << endl;
}
} while (!stop);
print_accts(bank);
system("pause");
return 0;
}
Account.cpp
#include "Account.hpp"
#include "Transaction.hpp"
Account::Account(void)
{
transactionCount = 0;
capacity = 101;
transactions = new Transaction[capacity];
}
Account::~Account(void)
{
delete[] transactions;
}
Account::Account(Depositor& depositor, double balance, int accountNumber, string
accountType, int status)
{
_depositor = depositor;
_balance = balance;
_accountNumber = accountNumber;
_accountType = accountType;
_status = status;
transactionCount = 0;
capacity = 101;
transactions = new Transaction[capacity];
}
Account::Account(const Account& account)
{
_depositor = account._depositor;
_balance = account._balance;
_accountNumber = account._accountNumber;
_accountType = account._accountType;
_status = account._status;
capacity = account.capacity;
transactionCount = account.transactionCount;
transactions = new Transaction[capacity];
for(int i=0; i=capacity-1)
{
capacity = capacity * 2;
Transaction* newTransaction = new Transaction[capacity];
for(int i=0; i_balance)
{
return false;
}
else
{
addTransaction(Transaction("withdraw", amount));
_balance -= amount;
return true;
}
}
void Account::open()
{
addTransaction(Transaction("open"));
_status = 1;
}
void Account::close()
{
addTransaction(Transaction("close"));
_status = 0;
}
bool Account::isClosed()
{
return _status==0;
}
Account.hpp
#ifndef Account_hpp
#define Account_hpp
#include
#include "Depositor.hpp"
#include "Transaction.hpp"
class Account
{
Depositor _depositor;
double _balance;
int _accountNumber;
string _accountType;
int _status;
int capacity;
int transactionCount;
Transaction* transactions;
public:
Account(void);
Account(Depositor& depositor, double balance, int accountNumber, string accountType, int
status);
Account(const Account& account);
~Account(void);
void addTransaction(Transaction transaction);
int getTransactionCount();
Transaction getTransaction(int index);
void open();
void close();
bool isClosed();
double getBalance();
Depositor& getDepositor();
int getAccountNumber();
string getAccountType();
void makeDeposit(double amount);
bool makeWithdrawal(double amount);
};
#endif /* Account_hpp */
Bank.cpp
#include "Bank.hpp"
Bank::Bank(void)
{
accountsNumber = 0;
}
Bank::~Bank(void)
{
}
int Bank::getAccounsNumber()
{
return accountsNumber;
}
bool Bank::openAccount(string firstName, string lastName, string ssn, int accountNumber, string
accountType, double balance)
{
if (addAccount(firstName, lastName, ssn, accountNumber, accountType, balance, 1))
{
int index = findAccount(accountNumber);
if (index>=0)
{
_accounts[index]->open();
}
return true;
}
return false;
}
bool Bank::addAccount(string firstName, string lastName, string ssn, int accountNumber, string
accountType, double balance, int status)
{
if (accountsNumbergetAccountNumber() == accountNumber)
return i;
}
return -1;
}
int Bank::findAccountSSN(string ssn)
{
for (int i = 0; igetDepositor().getSSN() == ssn)
return i;
}
return -1;
}
Account* Bank::getAccount(int index)
{
return _accounts[index];
}
bool Bank::deleteAccount(int index)
{
if (index >= 0 && index
#define MAX_NUM 100
#include "Account.hpp"
class Bank
{
Account* _accounts[MAX_NUM];
int accountsNumber;
public:
Bank(void);
~Bank(void);
bool openAccount(string firstName, string lastName, string ssn, int accountNumber, string
accountType, double balance);
bool addAccount(string firstName, string lastName, string ssn, int accountNumber, string
accountType, double balance, int status);
int findAccount(int accountNumber);
int findAccountSSN(string ssn);
Account* getAccount(int index);
bool deleteAccount(int index);
int getAccounsNumber();
};
#endif /* Bank_hpp */
Depositor.cpp
#include "Depositor.hpp"
Depositor::Depositor(void)
{
}
Depositor::~Depositor(void)
{
}
Depositor::Depositor(const Depositor& depositor)
{
_ssn = depositor._ssn;
_name = depositor._name;
}
Depositor::Depositor(Name& name, string ssn)
{
_ssn = ssn;
_name = name;
}
Name& Depositor::getName()
{
return _name;
}
string Depositor::getSSN()
{
return _ssn;
}
Depositor.hpp
#ifndef Depositor_hpp
#define Depositor_hpp
#include
#include "Name.hpp"
class Depositor
{
string _ssn;
Name _name;
public:
Depositor(void);
Depositor(const Depositor& depositor);
Depositor(Name& name, string ssn);
~Depositor(void);
Name& getName();
string getSSN();
};
#endif /* Depositor_hpp */
Name.cpp
#include "Name.hpp"
Name::Name(void)
{
}
Name::~Name(void)
{
}
Name::Name(const Name& name)
{
_firstName = name._firstName;
_lastName = name._lastName;
}
Name::Name(string firstName, string lastName)
{
_firstName = firstName;
_lastName = lastName;
}
string Name::getFirstname()
{
return _firstName;
}
string Name::getLastname()
{
return _lastName;
}
Name.hpp
#ifndef Name_hpp
#define Name_hpp
#include
#include
using namespace std;
class Name
{
string _firstName;
string _lastName;
public:
Name(void);
Name(const Name& name);
Name(string firstName, string lastName);
~Name(void);
string getFirstname();
string getLastname();
};
#endif /* Name_hpp */
Transaction.cpp
#include "Transaction.hpp"
Transaction::Transaction()
{
}
Transaction::Transaction(string transactionType, double amount)
{
_transactionType = transactionType;
_amount = amount;
}
Transaction::Transaction(string transactionType)
{
_transactionType = transactionType;
_amount = 0.0;
}
Transaction::Transaction(const Transaction& transaction)
{
_transactionType = transaction._transactionType;
_amount = transaction._amount;
}
Transaction::~Transaction(void)
{
}
string Transaction::getTransactionType()
{
return _transactionType;
}
double Transaction::getAmount()
{
return _amount;
}
Transaction.hpp
#include "Transaction.hpp"
Transaction::Transaction()
{
}
Transaction::Transaction(string transactionType, double amount)
{
_transactionType = transactionType;
_amount = amount;
}
Transaction::Transaction(string transactionType)
{
_transactionType = transactionType;
_amount = 0.0;
}
Transaction::Transaction(const Transaction& transaction)
{
_transactionType = transaction._transactionType;
_amount = transaction._amount;
}
Transaction::~Transaction(void)
{
}
string Transaction::getTransactionType()
{
return _transactionType;
}
double Transaction::getAmount()
{
return _amount;
}

More Related Content

Similar to main.cpp #include iostream #include iomanip #include fs.pdf

Shangz R Brown Presentation
Shangz R Brown PresentationShangz R Brown Presentation
Shangz R Brown Presentationshangbaby
 
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdfAccount.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdfanujmkt
 
Cbse class-xii-computer-science-projec
Cbse class-xii-computer-science-projecCbse class-xii-computer-science-projec
Cbse class-xii-computer-science-projecAniket Kumar
 
Cbse class-xii-computer-science-project
Cbse class-xii-computer-science-project Cbse class-xii-computer-science-project
Cbse class-xii-computer-science-project Aniket Kumar
 
You are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdfYou are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdfdeepakangel
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++Aqib Memon
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++Aqib Memon
 
The java class Account that simultes the Account class.pdf
   The java class Account that simultes  the Account class.pdf   The java class Account that simultes  the Account class.pdf
The java class Account that simultes the Account class.pdfakshay1213
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++Aqib Memon
 
Please distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfPlease distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfneerajsachdeva33
 
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THBANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THSHAJUS5
 
Write a banking program that simulates the operation of your local ba.docx
 Write a banking program that simulates the operation of your local ba.docx Write a banking program that simulates the operation of your local ba.docx
Write a banking program that simulates the operation of your local ba.docxajoy21
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++Aqib Memon
 
I need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdfI need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdfrajeshjangid1865
 
Bank Management System
Bank Management SystemBank Management System
Bank Management SystemBhaveshkumar92
 

Similar to main.cpp #include iostream #include iomanip #include fs.pdf (18)

Shangz R Brown Presentation
Shangz R Brown PresentationShangz R Brown Presentation
Shangz R Brown Presentation
 
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdfAccount.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
 
C programming
C programmingC programming
C programming
 
Cbse class-xii-computer-science-projec
Cbse class-xii-computer-science-projecCbse class-xii-computer-science-projec
Cbse class-xii-computer-science-projec
 
Cbse class-xii-computer-science-project
Cbse class-xii-computer-science-project Cbse class-xii-computer-science-project
Cbse class-xii-computer-science-project
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
You are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdfYou are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdf
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++
 
The java class Account that simultes the Account class.pdf
   The java class Account that simultes  the Account class.pdf   The java class Account that simultes  the Account class.pdf
The java class Account that simultes the Account class.pdf
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++
 
Please distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfPlease distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdf
 
Marcus Portfolio
Marcus  PortfolioMarcus  Portfolio
Marcus Portfolio
 
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THBANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
 
Write a banking program that simulates the operation of your local ba.docx
 Write a banking program that simulates the operation of your local ba.docx Write a banking program that simulates the operation of your local ba.docx
Write a banking program that simulates the operation of your local ba.docx
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++
 
I need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdfI need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdf
 
Bank Management System
Bank Management SystemBank Management System
Bank Management System
 

More from arwholesalelors

Algebra, branch of mathematics in which arithmetical operations and .pdf
Algebra, branch of mathematics in which arithmetical operations and .pdfAlgebra, branch of mathematics in which arithmetical operations and .pdf
Algebra, branch of mathematics in which arithmetical operations and .pdfarwholesalelors
 
AccuracyData accuracy mentions to the degree with which data prop.pdf
AccuracyData accuracy mentions to the degree with which data prop.pdfAccuracyData accuracy mentions to the degree with which data prop.pdf
AccuracyData accuracy mentions to the degree with which data prop.pdfarwholesalelors
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdfarwholesalelors
 
A) I will look for LP (limited partner) such as Yale Investment fund.pdf
A) I will look for LP (limited partner) such as Yale Investment fund.pdfA) I will look for LP (limited partner) such as Yale Investment fund.pdf
A) I will look for LP (limited partner) such as Yale Investment fund.pdfarwholesalelors
 
1. The Kepler space telescope detects planets and planet candidates .pdf
1. The Kepler space telescope detects planets and planet candidates .pdf1. The Kepler space telescope detects planets and planet candidates .pdf
1. The Kepler space telescope detects planets and planet candidates .pdfarwholesalelors
 
1. When cell in S phase is fused with cell in G1 phase, the cell of .pdf
1. When cell in S phase is fused with cell in G1 phase, the cell of .pdf1. When cell in S phase is fused with cell in G1 phase, the cell of .pdf
1. When cell in S phase is fused with cell in G1 phase, the cell of .pdfarwholesalelors
 
1. A Holds individuals accountable for their actions.2. E. A,B and.pdf
1. A Holds individuals accountable for their actions.2. E. A,B and.pdf1. A Holds individuals accountable for their actions.2. E. A,B and.pdf
1. A Holds individuals accountable for their actions.2. E. A,B and.pdfarwholesalelors
 
EtSH is the strongest acid, so EtS- is the weakest conjugate base. .pdf
  EtSH is the strongest acid, so EtS- is the weakest conjugate base.  .pdf  EtSH is the strongest acid, so EtS- is the weakest conjugate base.  .pdf
EtSH is the strongest acid, so EtS- is the weakest conjugate base. .pdfarwholesalelors
 
Particulars Amount $ Share Holders Funds Com.pdf
     Particulars  Amount $          Share Holders Funds            Com.pdf     Particulars  Amount $          Share Holders Funds            Com.pdf
Particulars Amount $ Share Holders Funds Com.pdfarwholesalelors
 
The Nitro group is electron withdrawing, and ther.pdf
                     The Nitro group is electron withdrawing, and ther.pdf                     The Nitro group is electron withdrawing, and ther.pdf
The Nitro group is electron withdrawing, and ther.pdfarwholesalelors
 
The Systems Development Life Cycle Moderate and large firms with uni.pdf
The Systems Development Life Cycle Moderate and large firms with uni.pdfThe Systems Development Life Cycle Moderate and large firms with uni.pdf
The Systems Development Life Cycle Moderate and large firms with uni.pdfarwholesalelors
 
You are asked to determine DNA content of a liver tissue. Describe h.pdf
You are asked to determine DNA content of a liver tissue. Describe h.pdfYou are asked to determine DNA content of a liver tissue. Describe h.pdf
You are asked to determine DNA content of a liver tissue. Describe h.pdfarwholesalelors
 
when we draw a vertical line it will cross the graph twice(that is m.pdf
when we draw a vertical line it will cross the graph twice(that is m.pdfwhen we draw a vertical line it will cross the graph twice(that is m.pdf
when we draw a vertical line it will cross the graph twice(that is m.pdfarwholesalelors
 
We Know that      Baking powder and Baking soda isused as a leave.pdf
We Know that      Baking powder and Baking soda isused as a leave.pdfWe Know that      Baking powder and Baking soda isused as a leave.pdf
We Know that      Baking powder and Baking soda isused as a leave.pdfarwholesalelors
 
The fallowing program shows the simple transformation #define GLEW.pdf
The fallowing program shows the simple transformation #define GLEW.pdfThe fallowing program shows the simple transformation #define GLEW.pdf
The fallowing program shows the simple transformation #define GLEW.pdfarwholesalelors
 
Two types of malware -1. Virus A virus is a contagious program o.pdf
Two types of malware -1. Virus A virus is a contagious program o.pdfTwo types of malware -1. Virus A virus is a contagious program o.pdf
Two types of malware -1. Virus A virus is a contagious program o.pdfarwholesalelors
 
TlI -- Tl+ + I- Ksp = 8.9E-8 = [Tl+][I-]          (eqn. 1) PbI2 .pdf
TlI -- Tl+ + I- Ksp = 8.9E-8 = [Tl+][I-]          (eqn. 1) PbI2 .pdfTlI -- Tl+ + I- Ksp = 8.9E-8 = [Tl+][I-]          (eqn. 1) PbI2 .pdf
TlI -- Tl+ + I- Ksp = 8.9E-8 = [Tl+][I-]          (eqn. 1) PbI2 .pdfarwholesalelors
 
The cells of the reproductive organs (Eg ovaries ad testes) undergo.pdf
The cells of the reproductive organs (Eg ovaries ad testes) undergo.pdfThe cells of the reproductive organs (Eg ovaries ad testes) undergo.pdf
The cells of the reproductive organs (Eg ovaries ad testes) undergo.pdfarwholesalelors
 
Scientific evidences I would give in support of evolution1. Paleo.pdf
Scientific evidences I would give in support of evolution1. Paleo.pdfScientific evidences I would give in support of evolution1. Paleo.pdf
Scientific evidences I would give in support of evolution1. Paleo.pdfarwholesalelors
 
Package scopeis the range of visibility for aparticular element or c.pdf
Package scopeis the range of visibility for aparticular element or c.pdfPackage scopeis the range of visibility for aparticular element or c.pdf
Package scopeis the range of visibility for aparticular element or c.pdfarwholesalelors
 

More from arwholesalelors (20)

Algebra, branch of mathematics in which arithmetical operations and .pdf
Algebra, branch of mathematics in which arithmetical operations and .pdfAlgebra, branch of mathematics in which arithmetical operations and .pdf
Algebra, branch of mathematics in which arithmetical operations and .pdf
 
AccuracyData accuracy mentions to the degree with which data prop.pdf
AccuracyData accuracy mentions to the degree with which data prop.pdfAccuracyData accuracy mentions to the degree with which data prop.pdf
AccuracyData accuracy mentions to the degree with which data prop.pdf
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
A) I will look for LP (limited partner) such as Yale Investment fund.pdf
A) I will look for LP (limited partner) such as Yale Investment fund.pdfA) I will look for LP (limited partner) such as Yale Investment fund.pdf
A) I will look for LP (limited partner) such as Yale Investment fund.pdf
 
1. The Kepler space telescope detects planets and planet candidates .pdf
1. The Kepler space telescope detects planets and planet candidates .pdf1. The Kepler space telescope detects planets and planet candidates .pdf
1. The Kepler space telescope detects planets and planet candidates .pdf
 
1. When cell in S phase is fused with cell in G1 phase, the cell of .pdf
1. When cell in S phase is fused with cell in G1 phase, the cell of .pdf1. When cell in S phase is fused with cell in G1 phase, the cell of .pdf
1. When cell in S phase is fused with cell in G1 phase, the cell of .pdf
 
1. A Holds individuals accountable for their actions.2. E. A,B and.pdf
1. A Holds individuals accountable for their actions.2. E. A,B and.pdf1. A Holds individuals accountable for their actions.2. E. A,B and.pdf
1. A Holds individuals accountable for their actions.2. E. A,B and.pdf
 
EtSH is the strongest acid, so EtS- is the weakest conjugate base. .pdf
  EtSH is the strongest acid, so EtS- is the weakest conjugate base.  .pdf  EtSH is the strongest acid, so EtS- is the weakest conjugate base.  .pdf
EtSH is the strongest acid, so EtS- is the weakest conjugate base. .pdf
 
Particulars Amount $ Share Holders Funds Com.pdf
     Particulars  Amount $          Share Holders Funds            Com.pdf     Particulars  Amount $          Share Holders Funds            Com.pdf
Particulars Amount $ Share Holders Funds Com.pdf
 
The Nitro group is electron withdrawing, and ther.pdf
                     The Nitro group is electron withdrawing, and ther.pdf                     The Nitro group is electron withdrawing, and ther.pdf
The Nitro group is electron withdrawing, and ther.pdf
 
The Systems Development Life Cycle Moderate and large firms with uni.pdf
The Systems Development Life Cycle Moderate and large firms with uni.pdfThe Systems Development Life Cycle Moderate and large firms with uni.pdf
The Systems Development Life Cycle Moderate and large firms with uni.pdf
 
You are asked to determine DNA content of a liver tissue. Describe h.pdf
You are asked to determine DNA content of a liver tissue. Describe h.pdfYou are asked to determine DNA content of a liver tissue. Describe h.pdf
You are asked to determine DNA content of a liver tissue. Describe h.pdf
 
when we draw a vertical line it will cross the graph twice(that is m.pdf
when we draw a vertical line it will cross the graph twice(that is m.pdfwhen we draw a vertical line it will cross the graph twice(that is m.pdf
when we draw a vertical line it will cross the graph twice(that is m.pdf
 
We Know that      Baking powder and Baking soda isused as a leave.pdf
We Know that      Baking powder and Baking soda isused as a leave.pdfWe Know that      Baking powder and Baking soda isused as a leave.pdf
We Know that      Baking powder and Baking soda isused as a leave.pdf
 
The fallowing program shows the simple transformation #define GLEW.pdf
The fallowing program shows the simple transformation #define GLEW.pdfThe fallowing program shows the simple transformation #define GLEW.pdf
The fallowing program shows the simple transformation #define GLEW.pdf
 
Two types of malware -1. Virus A virus is a contagious program o.pdf
Two types of malware -1. Virus A virus is a contagious program o.pdfTwo types of malware -1. Virus A virus is a contagious program o.pdf
Two types of malware -1. Virus A virus is a contagious program o.pdf
 
TlI -- Tl+ + I- Ksp = 8.9E-8 = [Tl+][I-]          (eqn. 1) PbI2 .pdf
TlI -- Tl+ + I- Ksp = 8.9E-8 = [Tl+][I-]          (eqn. 1) PbI2 .pdfTlI -- Tl+ + I- Ksp = 8.9E-8 = [Tl+][I-]          (eqn. 1) PbI2 .pdf
TlI -- Tl+ + I- Ksp = 8.9E-8 = [Tl+][I-]          (eqn. 1) PbI2 .pdf
 
The cells of the reproductive organs (Eg ovaries ad testes) undergo.pdf
The cells of the reproductive organs (Eg ovaries ad testes) undergo.pdfThe cells of the reproductive organs (Eg ovaries ad testes) undergo.pdf
The cells of the reproductive organs (Eg ovaries ad testes) undergo.pdf
 
Scientific evidences I would give in support of evolution1. Paleo.pdf
Scientific evidences I would give in support of evolution1. Paleo.pdfScientific evidences I would give in support of evolution1. Paleo.pdf
Scientific evidences I would give in support of evolution1. Paleo.pdf
 
Package scopeis the range of visibility for aparticular element or c.pdf
Package scopeis the range of visibility for aparticular element or c.pdfPackage scopeis the range of visibility for aparticular element or c.pdf
Package scopeis the range of visibility for aparticular element or c.pdf
 

Recently uploaded

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 

main.cpp #include iostream #include iomanip #include fs.pdf

  • 1. main.cpp #include #include #include #include #include "Bank.hpp" using namespace std; int read_accts(Bank& bank, int max_accts) { int i = 0; //ifstream infile("C:UsersSmart PCDesktopAssignment 3 (3110)myinput.txt"); ifstream infile("myinput"); string whiteSpace; getline(infile, whiteSpace); // check is file can be opened if (infile) { // read only first max_accts accounts, // in order to avoid overflow for (i = 0; i> firstName; // check is end of file reached if (!infile.eof()) { infile >> lastName; infile >> ssn; infile >> accountNumber; infile >> accountType; infile >> balance; infile >> status; infile >> transactions;
  • 2. bank.addAccount(firstName, lastName, ssn, accountNumber, accountType, balance, status); int index = bank.findAccount(accountNumber); Account* acc = bank.getAccount(index); for(int i=0; i> transactionType; infile >> amount; if (acc) acc->addTransaction(Transaction(transactionType, amount)); } } else { break; } } infile.close(); } else { cout << "cannot open inpout file" << endl; } return i; } */ void menu() { cout << "Select one of the following:" << endl << endl; cout << " W - Withdrawal" << endl; cout << " D - Deposit" << endl; cout << " N - New account" << endl; cout << " B - Balance" << endl; cout << " I - Account Info" << endl; cout << " H - Account Info plus Account Transaction History" << endl; cout << " C - Close Account (close but do not delete the account)" << endl;
  • 3. cout << " R - Reopen a closed account" << endl; cout << " X - Delete Account (close and delete the account from the database))" << endl; cout << " Q - Quit" << endl; } void withdrawal(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); if (index >= 0) { double amount; cout << "Enter amount to withdraw: "; cin >> amount; // check is there possible to withdraw if (amount>0) { // check is sufficient balance at account if (bank.getAccount(index)->makeWithdrawal(amount)) { cout << "Withdraw is completed." << endl; } else { cout << "Error. Insuffucient funds." << endl; } } else {
  • 4. cout << "Error. Invalid amount, needed to entyer positiove number." << endl; } } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void deposit(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); if (index >= 0) { double amount; cout << "Enter amount to deposit: "; cin >> amount; // check is there possible to withdraw if (amount>0) { bank.getAccount(index)->makeDeposit(amount); //deposit operation cout << "Deposit is completed." << endl;
  • 5. } else { cout << "Error. Invalid amount, needed to entyer positiove number." << endl; } } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void new_acct(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); if (index == -1) { double amount; string firstName; string lastName; string SSN; string accountType; cout << "Enter first name: "; cin >> firstName;
  • 6. cout << "Enter last name: "; cin >> lastName; do { cout << "Enter Social Security Number: "; cin >> SSN; // SSN is 9 digits, check for validity if (SSN.length() == 9) { break; } else { cout << "Error. Invalid SSN, needed to enter 9 digits. Pleasy try again." << endl; } } while (true); do { cout << "Enter Account type (C - Checking, S - Saving, D - CD) : "; cin >> accountType; // check for validity if (accountType == "C" || accountType == "S" || accountType == "D") { break; } else { cout << "Error. Invalid Account type. Please try again" << endl; } } while (true); do { cout << "Enter amount to deposit: "; cin >> amount;
  • 7. // check for validity if (amount>0) { break; } else { cout << "Error. Invalid amount, needed to entyer positiove number." << endl; } } while (true); if (bank.openAccount(firstName, lastName, SSN, requested_account, accountType, amount)) cout << "Account is opened." << endl; else cout << "Error. Cannot open account." << endl; } else { cout << "Error. Account number "" << requested_account << "" already exists." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void close_acct(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) {
  • 8. index = bank.findAccount(requested_account); Account* acc = bank.getAccount(index); if (index >= 0) { if (!acc->isClosed()) { acc->close(); cout << "Account number "" << requested_account << "" has been closed. "<< endl; } else { cout << "Error. Account number "" << requested_account << "" is already closed." << endl; } } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void reopen_acct(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account);
  • 9. Account* acc = bank.getAccount(index); if (index >= 0) { if (acc->isClosed()) { acc->open(); cout << "Account number "" << requested_account << "" has been reopened. "<< endl; } else { cout << "Error. Account number "" << requested_account << "" is already opened." << endl; } } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void delete_acct(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); if (index >= 0)
  • 10. { if (bank.deleteAccount(index)) cout << "Account is closed." << endl; else cout << "Error. Cannot close account." << endl; } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void balance(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); Account* acc = bank.getAccount(index); if (index >= 0) { acc->addTransaction(Transaction("banance")); cout << "Balance is: " << fixed << setprecision(2) << acc->getBalance() << endl; } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl;
  • 11. } } else { cout << "Error. Invalid account number." << endl; } } void account_info(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); Account* acc = bank.getAccount(index); if (index >= 0) { acc->addTransaction(Transaction("getinfo")); if (acc->getAccountType() == "S") cout << "Saving "; else if (acc->getAccountType() == "C") cout << "Checking "; else if (acc->getAccountType() == "D") cout << "CD "; cout << " Account #" << acc->getAccountNumber() << endl; cout << " Depositor info:" << endl; cout << " First name: " << acc->getDepositor().getName().getFirstname() << endl; cout << " Last name: " << acc->getDepositor().getName().getLastname() << endl; cout << " SSN: " << acc->getDepositor().getSSN() << endl;
  • 12. cout << " Balance is: " << fixed << setprecision(2) << acc->getBalance() << endl; } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void account_info_tr(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); Account* acc = bank.getAccount(index); if (index >= 0) { acc->addTransaction(Transaction("getinfo_tr")); if (acc->getAccountType() == "S") cout << "Saving "; else if (acc->getAccountType() == "C") cout << "Checking "; else if (acc->getAccountType() == "D") cout << "CD ";
  • 13. cout << " Account #" << acc->getAccountNumber() << endl; cout << " Depositor info:" << endl; cout << " First name: " << acc->getDepositor().getName().getFirstname() << endl; cout << " Last name: " << acc->getDepositor().getName().getLastname() << endl; cout << " SSN: " << acc->getDepositor().getSSN() << endl; cout << " Balance is: " << fixed << setprecision(2) << acc->getBalance() << endl; int trCount = acc->getTransactionCount(); cout << endl << "Transaction List: [" << trCount << " trsnsaction(s)]" << endl; for(int j=0; jgetTransaction(j).getTransactionType(); cout << "t"; if (acc->getTransaction(j).getAmount()>0) { cout << acc->getTransaction(j).getAmount(); } cout << endl; } } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } /* This function prints a table of the complete account information for every active account. */ void print_accts(Bank& bank) { ofstream outfile("myoutput.txt"); if (outfile)
  • 14. { for (int i = 0; i < bank.getAccounsNumber(); i++) { Account* acc = bank.getAccount(i); outfile << acc->getDepositor().getName().getFirstname(); outfile << "t"; outfile << acc->getDepositor().getName().getLastname(); outfile << "t"; outfile << acc->getDepositor().getSSN(); outfile << "t"; outfile << acc->getAccountNumber(); outfile << "t"; // save as char outfile << acc->getAccountType(); outfile << "t"; outfile << fixed << setprecision(2) << acc->getBalance(); outfile << "t"; outfile << fixed << setprecision(2) << (acc->isClosed() ? 0 : 1); outfile << "t"; outfile << fixed << setprecision(2) << acc->getTransactionCount(); outfile << endl; for(int j=0; jgetTransactionCount(); j++) { Transaction tr = acc->getTransaction(j); outfile << tr.getTransactionType(); outfile << "t"; outfile << tr.getAmount(); outfile << endl; } } outfile.close(); } else { cout << "Cannot open output file";
  • 15. } } int main() { string choice; Bank bank; int accountsNumber = 0; bool stop = false; accountsNumber = read_accts(bank, MAX_NUM); print_accts(bank); do { cout << endl; menu(); cout << "Your choice: "; cin >> choice; if (choice == "Q" || choice == "q") { stop = true; } else if (choice == "W" || choice == "w") { withdrawal(bank); } else if (choice == "D" || choice == "d") { deposit(bank); } else if (choice == "N" || choice == "n") { new_acct(bank); } else if (choice == "B" || choice == "b")
  • 16. { balance(bank); } else if (choice == "I" || choice == "i") { account_info(bank); } else if (choice == "H" || choice == "h") { account_info_tr(bank); } else if (choice == "C" || choice == "c") { close_acct(bank); } else if (choice == "R" || choice == "r") { reopen_acct(bank); } else if (choice == "X" || choice == "x") { delete_acct(bank); } else { cout << "Invalid choice, please try again." << endl; } } while (!stop); print_accts(bank); system("pause"); return 0; } Account.cpp
  • 17. #include "Account.hpp" #include "Transaction.hpp" Account::Account(void) { transactionCount = 0; capacity = 101; transactions = new Transaction[capacity]; } Account::~Account(void) { delete[] transactions; } Account::Account(Depositor& depositor, double balance, int accountNumber, string accountType, int status) { _depositor = depositor; _balance = balance; _accountNumber = accountNumber; _accountType = accountType; _status = status; transactionCount = 0; capacity = 101; transactions = new Transaction[capacity]; } Account::Account(const Account& account) { _depositor = account._depositor; _balance = account._balance; _accountNumber = account._accountNumber; _accountType = account._accountType; _status = account._status; capacity = account.capacity; transactionCount = account.transactionCount;
  • 18. transactions = new Transaction[capacity]; for(int i=0; i=capacity-1) { capacity = capacity * 2; Transaction* newTransaction = new Transaction[capacity]; for(int i=0; i_balance) { return false; } else { addTransaction(Transaction("withdraw", amount)); _balance -= amount; return true; } } void Account::open() { addTransaction(Transaction("open")); _status = 1; } void Account::close() { addTransaction(Transaction("close")); _status = 0; } bool Account::isClosed() { return _status==0; } Account.hpp #ifndef Account_hpp #define Account_hpp #include
  • 19. #include "Depositor.hpp" #include "Transaction.hpp" class Account { Depositor _depositor; double _balance; int _accountNumber; string _accountType; int _status; int capacity; int transactionCount; Transaction* transactions; public: Account(void); Account(Depositor& depositor, double balance, int accountNumber, string accountType, int status); Account(const Account& account); ~Account(void); void addTransaction(Transaction transaction); int getTransactionCount(); Transaction getTransaction(int index); void open(); void close(); bool isClosed(); double getBalance(); Depositor& getDepositor(); int getAccountNumber(); string getAccountType(); void makeDeposit(double amount); bool makeWithdrawal(double amount); }; #endif /* Account_hpp */
  • 20. Bank.cpp #include "Bank.hpp" Bank::Bank(void) { accountsNumber = 0; } Bank::~Bank(void) { } int Bank::getAccounsNumber() { return accountsNumber; } bool Bank::openAccount(string firstName, string lastName, string ssn, int accountNumber, string accountType, double balance) { if (addAccount(firstName, lastName, ssn, accountNumber, accountType, balance, 1)) { int index = findAccount(accountNumber); if (index>=0) { _accounts[index]->open(); } return true; } return false; } bool Bank::addAccount(string firstName, string lastName, string ssn, int accountNumber, string accountType, double balance, int status) { if (accountsNumbergetAccountNumber() == accountNumber) return i; } return -1;
  • 21. } int Bank::findAccountSSN(string ssn) { for (int i = 0; igetDepositor().getSSN() == ssn) return i; } return -1; } Account* Bank::getAccount(int index) { return _accounts[index]; } bool Bank::deleteAccount(int index) { if (index >= 0 && index #define MAX_NUM 100 #include "Account.hpp" class Bank { Account* _accounts[MAX_NUM]; int accountsNumber; public: Bank(void); ~Bank(void); bool openAccount(string firstName, string lastName, string ssn, int accountNumber, string accountType, double balance); bool addAccount(string firstName, string lastName, string ssn, int accountNumber, string accountType, double balance, int status); int findAccount(int accountNumber); int findAccountSSN(string ssn); Account* getAccount(int index); bool deleteAccount(int index); int getAccounsNumber();
  • 22. }; #endif /* Bank_hpp */ Depositor.cpp #include "Depositor.hpp" Depositor::Depositor(void) { } Depositor::~Depositor(void) { } Depositor::Depositor(const Depositor& depositor) { _ssn = depositor._ssn; _name = depositor._name; } Depositor::Depositor(Name& name, string ssn) { _ssn = ssn; _name = name; } Name& Depositor::getName() { return _name; } string Depositor::getSSN() { return _ssn; } Depositor.hpp #ifndef Depositor_hpp #define Depositor_hpp #include #include "Name.hpp"
  • 23. class Depositor { string _ssn; Name _name; public: Depositor(void); Depositor(const Depositor& depositor); Depositor(Name& name, string ssn); ~Depositor(void); Name& getName(); string getSSN(); }; #endif /* Depositor_hpp */ Name.cpp #include "Name.hpp" Name::Name(void) { } Name::~Name(void) { } Name::Name(const Name& name) { _firstName = name._firstName; _lastName = name._lastName; } Name::Name(string firstName, string lastName) { _firstName = firstName; _lastName = lastName; } string Name::getFirstname() {
  • 24. return _firstName; } string Name::getLastname() { return _lastName; } Name.hpp #ifndef Name_hpp #define Name_hpp #include #include using namespace std; class Name { string _firstName; string _lastName; public: Name(void); Name(const Name& name); Name(string firstName, string lastName); ~Name(void); string getFirstname(); string getLastname(); }; #endif /* Name_hpp */ Transaction.cpp #include "Transaction.hpp" Transaction::Transaction() { } Transaction::Transaction(string transactionType, double amount) {
  • 25. _transactionType = transactionType; _amount = amount; } Transaction::Transaction(string transactionType) { _transactionType = transactionType; _amount = 0.0; } Transaction::Transaction(const Transaction& transaction) { _transactionType = transaction._transactionType; _amount = transaction._amount; } Transaction::~Transaction(void) { } string Transaction::getTransactionType() { return _transactionType; } double Transaction::getAmount() { return _amount; } Transaction.hpp #include "Transaction.hpp" Transaction::Transaction() { } Transaction::Transaction(string transactionType, double amount) { _transactionType = transactionType; _amount = amount; } Transaction::Transaction(string transactionType) {
  • 26. _transactionType = transactionType; _amount = 0.0; } Transaction::Transaction(const Transaction& transaction) { _transactionType = transaction._transactionType; _amount = transaction._amount; } Transaction::~Transaction(void) { } string Transaction::getTransactionType() { return _transactionType; } double Transaction::getAmount() { return _amount; } Solution main.cpp #include #include #include #include #include "Bank.hpp" using namespace std; int read_accts(Bank& bank, int max_accts) { int i = 0; //ifstream infile("C:UsersSmart PCDesktopAssignment 3 (3110)myinput.txt"); ifstream infile("myinput");
  • 27. string whiteSpace; getline(infile, whiteSpace); // check is file can be opened if (infile) { // read only first max_accts accounts, // in order to avoid overflow for (i = 0; i> firstName; // check is end of file reached if (!infile.eof()) { infile >> lastName; infile >> ssn; infile >> accountNumber; infile >> accountType; infile >> balance; infile >> status; infile >> transactions; bank.addAccount(firstName, lastName, ssn, accountNumber, accountType, balance, status); int index = bank.findAccount(accountNumber); Account* acc = bank.getAccount(index); for(int i=0; i> transactionType; infile >> amount; if (acc) acc->addTransaction(Transaction(transactionType, amount)); } } else { break;
  • 28. } } infile.close(); } else { cout << "cannot open inpout file" << endl; } return i; } */ void menu() { cout << "Select one of the following:" << endl << endl; cout << " W - Withdrawal" << endl; cout << " D - Deposit" << endl; cout << " N - New account" << endl; cout << " B - Balance" << endl; cout << " I - Account Info" << endl; cout << " H - Account Info plus Account Transaction History" << endl; cout << " C - Close Account (close but do not delete the account)" << endl; cout << " R - Reopen a closed account" << endl; cout << " X - Delete Account (close and delete the account from the database))" << endl; cout << " Q - Quit" << endl; } void withdrawal(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) {
  • 29. index = bank.findAccount(requested_account); if (index >= 0) { double amount; cout << "Enter amount to withdraw: "; cin >> amount; // check is there possible to withdraw if (amount>0) { // check is sufficient balance at account if (bank.getAccount(index)->makeWithdrawal(amount)) { cout << "Withdraw is completed." << endl; } else { cout << "Error. Insuffucient funds." << endl; } } else { cout << "Error. Invalid amount, needed to entyer positiove number." << endl; } } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void deposit(Bank& bank) { int index, requested_account;
  • 30. //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); if (index >= 0) { double amount; cout << "Enter amount to deposit: "; cin >> amount; // check is there possible to withdraw if (amount>0) { bank.getAccount(index)->makeDeposit(amount); //deposit operation cout << "Deposit is completed." << endl; } else { cout << "Error. Invalid amount, needed to entyer positiove number." << endl; } } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void new_acct(Bank& bank)
  • 31. { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); if (index == -1) { double amount; string firstName; string lastName; string SSN; string accountType; cout << "Enter first name: "; cin >> firstName; cout << "Enter last name: "; cin >> lastName; do { cout << "Enter Social Security Number: "; cin >> SSN; // SSN is 9 digits, check for validity if (SSN.length() == 9) { break; } else { cout << "Error. Invalid SSN, needed to enter 9 digits. Pleasy try again." << endl; } } while (true);
  • 32. do { cout << "Enter Account type (C - Checking, S - Saving, D - CD) : "; cin >> accountType; // check for validity if (accountType == "C" || accountType == "S" || accountType == "D") { break; } else { cout << "Error. Invalid Account type. Please try again" << endl; } } while (true); do { cout << "Enter amount to deposit: "; cin >> amount; // check for validity if (amount>0) { break; } else { cout << "Error. Invalid amount, needed to entyer positiove number." << endl; } } while (true); if (bank.openAccount(firstName, lastName, SSN, requested_account, accountType, amount)) cout << "Account is opened." << endl; else cout << "Error. Cannot open account." << endl;
  • 33. } else { cout << "Error. Account number "" << requested_account << "" already exists." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void close_acct(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); Account* acc = bank.getAccount(index); if (index >= 0) { if (!acc->isClosed()) { acc->close(); cout << "Account number "" << requested_account << "" has been closed. "<< endl; } else { cout << "Error. Account number "" << requested_account << "" is already closed." << endl; } }
  • 34. else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void reopen_acct(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); Account* acc = bank.getAccount(index); if (index >= 0) { if (acc->isClosed()) { acc->open(); cout << "Account number "" << requested_account << "" has been reopened. "<< endl; } else { cout << "Error. Account number "" << requested_account << "" is already opened." << endl; } } else {
  • 35. cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void delete_acct(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); if (index >= 0) { if (bank.deleteAccount(index)) cout << "Account is closed." << endl; else cout << "Error. Cannot close account." << endl; } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } }
  • 36. void balance(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); Account* acc = bank.getAccount(index); if (index >= 0) { acc->addTransaction(Transaction("banance")); cout << "Balance is: " << fixed << setprecision(2) << acc->getBalance() << endl; } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void account_info(Bank& bank) { int index, requested_account; //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid
  • 37. if (requested_account != 0) { index = bank.findAccount(requested_account); Account* acc = bank.getAccount(index); if (index >= 0) { acc->addTransaction(Transaction("getinfo")); if (acc->getAccountType() == "S") cout << "Saving "; else if (acc->getAccountType() == "C") cout << "Checking "; else if (acc->getAccountType() == "D") cout << "CD "; cout << " Account #" << acc->getAccountNumber() << endl; cout << " Depositor info:" << endl; cout << " First name: " << acc->getDepositor().getName().getFirstname() << endl; cout << " Last name: " << acc->getDepositor().getName().getLastname() << endl; cout << " SSN: " << acc->getDepositor().getSSN() << endl; cout << " Balance is: " << fixed << setprecision(2) << acc->getBalance() << endl; } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } void account_info_tr(Bank& bank) { int index, requested_account;
  • 38. //prompt for account number cout << endl << "Enter the account number: "; cin >> requested_account; // account #0 is not valid if (requested_account != 0) { index = bank.findAccount(requested_account); Account* acc = bank.getAccount(index); if (index >= 0) { acc->addTransaction(Transaction("getinfo_tr")); if (acc->getAccountType() == "S") cout << "Saving "; else if (acc->getAccountType() == "C") cout << "Checking "; else if (acc->getAccountType() == "D") cout << "CD "; cout << " Account #" << acc->getAccountNumber() << endl; cout << " Depositor info:" << endl; cout << " First name: " << acc->getDepositor().getName().getFirstname() << endl; cout << " Last name: " << acc->getDepositor().getName().getLastname() << endl; cout << " SSN: " << acc->getDepositor().getSSN() << endl; cout << " Balance is: " << fixed << setprecision(2) << acc->getBalance() << endl; int trCount = acc->getTransactionCount(); cout << endl << "Transaction List: [" << trCount << " trsnsaction(s)]" << endl; for(int j=0; jgetTransaction(j).getTransactionType(); cout << "t"; if (acc->getTransaction(j).getAmount()>0) { cout << acc->getTransaction(j).getAmount(); }
  • 39. cout << endl; } } else { cout << "Error. Account number "" << requested_account << "" is not found." << endl; } } else { cout << "Error. Invalid account number." << endl; } } /* This function prints a table of the complete account information for every active account. */ void print_accts(Bank& bank) { ofstream outfile("myoutput.txt"); if (outfile) { for (int i = 0; i < bank.getAccounsNumber(); i++) { Account* acc = bank.getAccount(i); outfile << acc->getDepositor().getName().getFirstname(); outfile << "t"; outfile << acc->getDepositor().getName().getLastname(); outfile << "t"; outfile << acc->getDepositor().getSSN(); outfile << "t"; outfile << acc->getAccountNumber(); outfile << "t"; // save as char outfile << acc->getAccountType();
  • 40. outfile << "t"; outfile << fixed << setprecision(2) << acc->getBalance(); outfile << "t"; outfile << fixed << setprecision(2) << (acc->isClosed() ? 0 : 1); outfile << "t"; outfile << fixed << setprecision(2) << acc->getTransactionCount(); outfile << endl; for(int j=0; jgetTransactionCount(); j++) { Transaction tr = acc->getTransaction(j); outfile << tr.getTransactionType(); outfile << "t"; outfile << tr.getAmount(); outfile << endl; } } outfile.close(); } else { cout << "Cannot open output file"; } } int main() { string choice; Bank bank; int accountsNumber = 0; bool stop = false; accountsNumber = read_accts(bank, MAX_NUM); print_accts(bank); do { cout << endl;
  • 41. menu(); cout << "Your choice: "; cin >> choice; if (choice == "Q" || choice == "q") { stop = true; } else if (choice == "W" || choice == "w") { withdrawal(bank); } else if (choice == "D" || choice == "d") { deposit(bank); } else if (choice == "N" || choice == "n") { new_acct(bank); } else if (choice == "B" || choice == "b") { balance(bank); } else if (choice == "I" || choice == "i") { account_info(bank); } else if (choice == "H" || choice == "h") { account_info_tr(bank); } else if (choice == "C" || choice == "c") { close_acct(bank); }
  • 42. else if (choice == "R" || choice == "r") { reopen_acct(bank); } else if (choice == "X" || choice == "x") { delete_acct(bank); } else { cout << "Invalid choice, please try again." << endl; } } while (!stop); print_accts(bank); system("pause"); return 0; } Account.cpp #include "Account.hpp" #include "Transaction.hpp" Account::Account(void) { transactionCount = 0; capacity = 101; transactions = new Transaction[capacity]; } Account::~Account(void) { delete[] transactions; } Account::Account(Depositor& depositor, double balance, int accountNumber, string accountType, int status)
  • 43. { _depositor = depositor; _balance = balance; _accountNumber = accountNumber; _accountType = accountType; _status = status; transactionCount = 0; capacity = 101; transactions = new Transaction[capacity]; } Account::Account(const Account& account) { _depositor = account._depositor; _balance = account._balance; _accountNumber = account._accountNumber; _accountType = account._accountType; _status = account._status; capacity = account.capacity; transactionCount = account.transactionCount; transactions = new Transaction[capacity]; for(int i=0; i=capacity-1) { capacity = capacity * 2; Transaction* newTransaction = new Transaction[capacity]; for(int i=0; i_balance) { return false; } else { addTransaction(Transaction("withdraw", amount)); _balance -= amount; return true;
  • 44. } } void Account::open() { addTransaction(Transaction("open")); _status = 1; } void Account::close() { addTransaction(Transaction("close")); _status = 0; } bool Account::isClosed() { return _status==0; } Account.hpp #ifndef Account_hpp #define Account_hpp #include #include "Depositor.hpp" #include "Transaction.hpp" class Account { Depositor _depositor; double _balance; int _accountNumber; string _accountType; int _status; int capacity; int transactionCount; Transaction* transactions; public: Account(void);
  • 45. Account(Depositor& depositor, double balance, int accountNumber, string accountType, int status); Account(const Account& account); ~Account(void); void addTransaction(Transaction transaction); int getTransactionCount(); Transaction getTransaction(int index); void open(); void close(); bool isClosed(); double getBalance(); Depositor& getDepositor(); int getAccountNumber(); string getAccountType(); void makeDeposit(double amount); bool makeWithdrawal(double amount); }; #endif /* Account_hpp */ Bank.cpp #include "Bank.hpp" Bank::Bank(void) { accountsNumber = 0; } Bank::~Bank(void) { } int Bank::getAccounsNumber() { return accountsNumber; }
  • 46. bool Bank::openAccount(string firstName, string lastName, string ssn, int accountNumber, string accountType, double balance) { if (addAccount(firstName, lastName, ssn, accountNumber, accountType, balance, 1)) { int index = findAccount(accountNumber); if (index>=0) { _accounts[index]->open(); } return true; } return false; } bool Bank::addAccount(string firstName, string lastName, string ssn, int accountNumber, string accountType, double balance, int status) { if (accountsNumbergetAccountNumber() == accountNumber) return i; } return -1; } int Bank::findAccountSSN(string ssn) { for (int i = 0; igetDepositor().getSSN() == ssn) return i; } return -1; } Account* Bank::getAccount(int index) { return _accounts[index]; } bool Bank::deleteAccount(int index) { if (index >= 0 && index
  • 47. #define MAX_NUM 100 #include "Account.hpp" class Bank { Account* _accounts[MAX_NUM]; int accountsNumber; public: Bank(void); ~Bank(void); bool openAccount(string firstName, string lastName, string ssn, int accountNumber, string accountType, double balance); bool addAccount(string firstName, string lastName, string ssn, int accountNumber, string accountType, double balance, int status); int findAccount(int accountNumber); int findAccountSSN(string ssn); Account* getAccount(int index); bool deleteAccount(int index); int getAccounsNumber(); }; #endif /* Bank_hpp */ Depositor.cpp #include "Depositor.hpp" Depositor::Depositor(void) { } Depositor::~Depositor(void) { } Depositor::Depositor(const Depositor& depositor) { _ssn = depositor._ssn; _name = depositor._name;
  • 48. } Depositor::Depositor(Name& name, string ssn) { _ssn = ssn; _name = name; } Name& Depositor::getName() { return _name; } string Depositor::getSSN() { return _ssn; } Depositor.hpp #ifndef Depositor_hpp #define Depositor_hpp #include #include "Name.hpp" class Depositor { string _ssn; Name _name; public: Depositor(void); Depositor(const Depositor& depositor); Depositor(Name& name, string ssn); ~Depositor(void); Name& getName(); string getSSN(); }; #endif /* Depositor_hpp */
  • 49. Name.cpp #include "Name.hpp" Name::Name(void) { } Name::~Name(void) { } Name::Name(const Name& name) { _firstName = name._firstName; _lastName = name._lastName; } Name::Name(string firstName, string lastName) { _firstName = firstName; _lastName = lastName; } string Name::getFirstname() { return _firstName; } string Name::getLastname() { return _lastName; } Name.hpp #ifndef Name_hpp #define Name_hpp #include #include using namespace std; class Name {
  • 50. string _firstName; string _lastName; public: Name(void); Name(const Name& name); Name(string firstName, string lastName); ~Name(void); string getFirstname(); string getLastname(); }; #endif /* Name_hpp */ Transaction.cpp #include "Transaction.hpp" Transaction::Transaction() { } Transaction::Transaction(string transactionType, double amount) { _transactionType = transactionType; _amount = amount; } Transaction::Transaction(string transactionType) { _transactionType = transactionType; _amount = 0.0; } Transaction::Transaction(const Transaction& transaction) { _transactionType = transaction._transactionType; _amount = transaction._amount; } Transaction::~Transaction(void) {
  • 51. } string Transaction::getTransactionType() { return _transactionType; } double Transaction::getAmount() { return _amount; } Transaction.hpp #include "Transaction.hpp" Transaction::Transaction() { } Transaction::Transaction(string transactionType, double amount) { _transactionType = transactionType; _amount = amount; } Transaction::Transaction(string transactionType) { _transactionType = transactionType; _amount = 0.0; } Transaction::Transaction(const Transaction& transaction) { _transactionType = transaction._transactionType; _amount = transaction._amount; } Transaction::~Transaction(void) { } string Transaction::getTransactionType() { return _transactionType; }