-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusebrass2.cpp
58 lines (56 loc) · 1.25 KB
/
usebrass2.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
// usebrass2.cpp -- polymorphic example
// compile with brass.cpp
#include <iostream>
#include "brass.h"
const int CLIENTS = 4;
const int LEN = 40;
int main()
{
using std::cin;
using std::cout;
using std::endl;
Brass * p_clients[CLIENTS];
int i;
for (i = 0; i < CLIENTS; i++) {
char temp[LEN];
long tempnum;
double tempbal;
char kind;
cout << "Enter client's name: ";
cin.getline (temp, LEN);
cout << "Enter client's accout number: ";
cin >> tempnum;
cout << "Enter opening balance: $";
cin >> tempbal;
cout << "Enter 1 for Brass Account or "
<< "2 for BrassPlus Account: ";
while (cin >> kind && (kind != '1' && kind != '2')) {
cout << "Enter either 1 or 2: ";
}
if (kind == '1') {
p_clients[i] = new Brass (temp, tempnum, tempbal);
} else {
double tmax, trate;
cout << "Enter the overdraft limit: $";
cin >> tmax;
cout << "Enter the interest rate "
<< "as a decimal fraction: ";
cin >> trate;
p_clients[i] = new BrassPlus(temp, tempnum, tempbal,
tmax, trate);
}
while (cin.get() != '\n') {
continue;
}
}
cout << endl;
for (i = 0; i < CLIENTS; i++) {
p_clients[i]->ViewAcct();
cout << endl;
}
for (i = 0; i < CLIENTS; i++) {
delete p_clients[i];
}
cout << "Done.\n";
return 0;
}