-
Notifications
You must be signed in to change notification settings - Fork 0
/
Source.cpp
241 lines (181 loc) · 6.19 KB
/
Source.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#include<iostream>
#include<string>
#include<vector>
#include"BankAccount.h"
#include"SavingsAccount.h"
#include"WalletAccount.h"
using namespace std;
int main() {
string choice;
int number;
unsigned int i;
vector<SavingsAccount*> accounts;
SavingsAccount *accountPtr;
vector<WalletAccount*> wAccounts;
WalletAccount *wAccountPtr;
cout << "Savings Accounts Open: " << accounts.size() << endl;
cout << "Wallet Accounts Open: " << wAccounts.size() << endl;
cout << "Total Accounts Open: " << accounts.size() + wAccounts.size() << endl << endl;
while (choice != "No") {
cout << "\nWould you like to open a 2% savings account?" << endl;
cin >> choice;
if (choice == "Yes" || choice == "yes") {
cout << "\nPlease enter the balance of the account: " << endl;
cin >> number;
if (number > 0) {
accountPtr = new SavingsAccount(number, .02, 1, false);
accounts.push_back(accountPtr);
cout << "\nA complementary Wallet Account is included with your Banking Account" << endl;
cout << "Would you like to add any funds to the Wallet Account?" << endl;
cout << "It can hold up to $100" << endl;
cin >> choice;
}
else if (number <= 0) {
cout << "The balance must be greater that $1" << endl;
cout << "Would you like to open a Wallet Account instead?" << endl;
cout << "It can hold up to $100" << endl;
cin >> choice;
}
if (choice == "Yes" || choice == "yes") {
cout << "How much will you be adding to the Wallet?" << endl;
cin >> number;
if (number > 0 && number <= 100) {
wAccountPtr = new WalletAccount(number, .02, wAccounts.size());
wAccounts.push_back(wAccountPtr);
}
else if (number > 100 || number <= 0)
cout << "The amount entered is not allowed" << endl;
}
else if (choice == "No" || choice == "no") {
wAccountPtr = new WalletAccount(0, .02, wAccounts.size());
wAccounts.push_back(wAccountPtr);
}
}
else
choice = "No";
}
cout << "There are currently " << accounts.size() << " saving accounts currently open\n\n";
cout << "There are currently " << wAccounts.size() << " wallet accounts open\n\n";
cout << "\n\n";
for (i = 0; i < (accounts.size() + wAccounts.size()); ++i) {
if (i < accounts.size()) {
int l = accounts.at(i)->getBalance();
if (i < wAccounts.size()) {
int k = wAccounts.at(i)->getBalance();
cout << "--------------------------------" << endl;
cout << "Aggregated Funds: " << (l + k) << endl;
}
else
cout << "Aggregated Funds: " << (l) << endl;
}
}
cout << "Contents:" << endl << endl;
for (i = 0; i < accounts.size(); ++i) {
cout << "Account ID: " << i + 1000 << endl;
accounts.at(i)->printInfo();
}
for (i = 0; i < wAccounts.size(); ++i) {
cout << "Account ID: " << i + 1000 << endl;
wAccounts.at(i)->printInfo();
}
choice = "reset";
while (choice != "No") {
cout << "Do any accounts need to be deleted?" << endl;
cin >> choice;
if (choice == "Yes" || choice == "yes") {
cout << "Please select the Account ID that needs to be deleted" << endl;
cin >> number;
i = number - 1000;
if ((i) < accounts.size()) {
accounts.erase(accounts.begin() + (i), accounts.begin() + (i) + 1);
}
if ((i) < wAccounts.size()) {
wAccounts.erase(wAccounts.begin() + (i), wAccounts.begin() + (i) + 1);
}
else
cout << "Entered number was not in the range of any index" << endl;
}
else
choice = "No";
}
cout << "\n\n";
for (i = 0; i < accounts.size(); ++i) {
cout << "Account ID: " << i + 1000 << endl;
accounts.at(i)->printInfo();
}
for (i = 0; i < wAccounts.size(); ++i) {
cout << "Account ID: " << i + 1000 << endl;
wAccounts.at(i)->printInfo();
}
cout << "\n\n";
choice = "Reset";
while (choice != "No") {
cout << "Are any further deposits required?" << endl;
cin >> choice;
if (choice == "Yes" || choice == "yes") {
cout << "Are you adding to a Savings or Wallet Account?" << endl;
cout << "Type: 'Savings' or 'Wallet'" << endl;
cin >> choice;
if (choice == "Savings") {
cout << "What ID do you need to deposit in?" << endl;
cin >> i;
cout << "How much are you depositing: " << endl;
cin >> number;
accounts.at(i-1000)->deposit(number);
cout << "Updated Information for the account is: " << endl;
accounts.at(i-1000)->printInfo();
}
else if (choice == "Wallet") {
cout << "What ID do you need to deposit in?" << endl;
cin >> i;
cout << "How much are you depositing: " << endl;
cin >> number;
if ((wAccounts.at(i-1000)->getBalance() + number) <= 100)
wAccounts.at(i-1000)->deposit(number);
else if ((wAccounts.at(i-1000)->getBalance() + number) > 100)
cout << "The wallet account can not exceed $100, please try again." << endl;
cout << "Updated Information for the account is: " << endl;
wAccounts.at(i-1000)->printInfo();
}
else
cout << "Please check your input, and try again" << endl;
}
else
choice = "No";
}
for (i = 0; i < accounts.size(); ++i) {
cout << "Account ID: " << i + 1000 << endl;
accounts.at(i)->printInfo();
}
for (i = 0; i < wAccounts.size(); ++i) {
cout << "Account ID: " << i + 1000 << endl;
wAccounts.at(i)->printInfo();
}
for (i = 0; i < accounts.size(); ++i) {
double largest = accounts.at(i)->getBalance();
if (largest < accounts.at(i)->getBalance()) {
largest = accounts.at(i)->getBalance();
}
if (i = accounts.size()) {
cout << "The ID of the largest Account is: " << endl;
cout << "The largest account holds: $" << largest << endl;
}
}
cout << "Please enter the account number you are looking for: " << endl;
cin >> number;
if ((number-1000) >= accounts.size()) {
cout << "There is no Savings Account associated with this ID" << endl;
}
else if ((number-1000) <= accounts.size())
accounts.at(number-1000)->printInfo();
if ((number-1000) >= wAccounts.size()) {
cout << "There is no Wallet Account for this ID" << endl;
}
else if ((number-1000) <= wAccounts.size())
wAccounts.at(number-1000)->printInfo();
cout << "Savings Accounts Open: " << accounts.size() << endl;
cout << "Wallet Accounts Open: " << wAccounts.size() << endl;
cout << "\nTotal Accounts Open: " << accounts.size() + wAccounts.size() << endl;
char exit;
cin >> exit;
}