-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBankData.cpp
executable file
·73 lines (58 loc) · 1.93 KB
/
BankData.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "BankData.h"
#include <fstream>
using namespace std;
BankData::BankData()
{
Customers = new Customer[25];
ChkAccounts = new Checking[25];
SavAccounts = new Savings[25];
RecordCount = 0;
MaximumAccounts = 25;
}
void BankData::AddAccount(int cid, int sid, int pin, double cbal, double sbal, double sint, bool odflag)
{
if (RecordCount > MaximumAccounts+1)
{
Customer* tmp = new Customer[MaximumAccounts];
for (int i=0;i<MaximumAccounts;++i)
tmp[i] = Customers[i];
Customers = new Customer[MaximumAccounts*2];
for (int i=0;i<MaximumAccounts;++i)
Customers[i] = tmp[i];
delete[] tmp;
MaximumAccounts *= 2;
}
Customers[RecordCount].SetID(RecordCount+1);
Customers[RecordCount].SetCheckingID(cid);
Customers[RecordCount].SetSavingsID(sid);
Customers[RecordCount].SetPIN(pin);
Customers[RecordCount].SetCheckingBal(cbal);
Customers[RecordCount].SetSavingsBal(sbal);
Customers[RecordCount].SetSavingsInt(sint);
Customers[RecordCount].SetOverdraft(odflag);
++RecordCount;
}
void BankData::WriteCustomersToFile()
{
ofstream file;
file.open("AccountReport.txt");
file << this;
file.close();
}
std::ostream& operator<< (std::ostream& os, BankData* dat)
{
for (int i=0;i<dat->GetRecordCount();++i)
{
os << "Customer ID: " << dat->GetCustomer(i).GetID() << endl
<< "PIN: " << dat->GetCustomer(i).GetPIN() << endl
<< "Name: " << dat->GetCustomer(i).GetName() << endl
<< "Address: " << dat->GetCustomer(i).GetCustomerInfo() << endl
<< "Checking Acct No.: " << dat->GetCustomer(i).GetCheckingID() << endl
<< "Checking Acct Bal: $" << setprecision(2) << dat->GetCustomer(i).GetCheckingBal() << endl
<< "Overdraft: " << dat->GetCustomer(i).GetOverdraft() << endl
<< "Savings Acct No.: " << dat->GetCustomer(i).GetSavingsID() << endl
<< "Savings Acct Bal: $" << setprecision(2) << dat->GetCustomer(i).GetSavingsBal() << " (" << dat->GetCustomer(i).GetSavingsInt() << "%)" << endl
<< endl;
}
return os;
}