-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
239 lines (192 loc) · 5.16 KB
/
main.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
#include <iostream>
#include <string.h>
#include "Accounts.h"
#include "Account.h"
#include "Savings.h"
#include "Fd.h"
#include "Loan.h"
#include "FixedLoan.h"
#include "VariableLoan.h"
#include "user.h"
using namespace std;
//function Implementations.
/////////////////////////////////////////////////
void newHomeLoan()
{
int type;
while (true)
{
cout << "\nWhich type of account would you like: "
<< "\n"
<< "\n1. Fixed rate \n"
<< "\n2. Variable rate \n";
cout << "\nSelect an Option: ";
if (cin >> type && (type == 1 || type == 2))
break;
cin.clear();
cin.ignore(120, '\n');
cout << "Error, please try again: " << endl;
}
if (type == 1)
{
Loan *NewLoan = new FixedLoan;
NewLoan->create_account(type);
}
else if (type == 2)
{
Loan *NewLoan = new VariableLoan;
NewLoan->create_account(type);
}
}
void display_acc_details()
{
Loan *ShowLoan = new FixedLoan;
ShowLoan->show_account();
}
void modify_account()
{
Loan *ModifyLoan = new FixedLoan;
ModifyLoan->modify();
}
void deposit()
{
Loan *LoanDeposit = new FixedLoan;
LoanDeposit->dep();
}
void start_program_Loan(){
int choice;
while (1)
{
while (true)
{
cout << "\n\t\tlOAN MENU";
cout << "\n====================================================";
cout << "\n1. NEW LOAN ACCOUNT";
cout << "\n2. SHOW EXISTING ACCOUNT";
cout << "\n3. CHANGE LOAN TYPE TO VARIABLE";
cout << "\n4. DEPOSIT ON EXISTING ACCOUNT";
cout << "\n5. LOG OUT";
cout << "\n====================================================";
cout << "\nSelect an Option: ";
if (cin >> choice && (choice == 1 || choice == 2 || choice == 3 || choice == 4 || choice == 5))
break;
cin.clear();
cin.ignore(120, '\n');
cout << "Error, please try again: " << endl;
}
switch (choice)
{
case 1: //new account
newHomeLoan();
break;
case 2: //show account
display_acc_details();
break;
case 3:
modify_account();
break;
case 4:
deposit();
break;
case 5:
if (system("CLS")) system("clear");
cout << "Thankyou for using our system!" << endl;
exit(0);
break;
default:
if (system("CLS")) system("clear");
cout << "invalid option!" << endl;
break;
}
if(choice == 5)
{
break;
}
}
}
void start_program_Account(){
int Cash;
cout << endl;
cout << "How much cash do you currently have: ";
while(true)
{
if(cin >> Cash && Cash >= 0)
{
break;
}
cout << endl;
cin.clear();
cin.ignore(120,'\n');
cout << "Please enter in a valid cash amount: ";
}
cout << endl;
Accounts User(Cash);
Savings Savings(500,"Savings","Car");
Fd FixedDeposit(5000, "FixedDeposit",10);
User.AddSavAccount(Savings);
User.AddFdAccount(FixedDeposit);
User.choice();
}
void start_program()
{
if (system("CLS")) system("clear");
std::cout << "___________________________________________________________"<< std::endl;
cout<<endl;
std::cout << "WELCOME TO OUR INTERNET BANKING SYSTEM!"<< std::endl;
std::cout << "___________________________________________________________"<< std::endl;
cout<<endl;
string entereduser;
std::cout<< "Please enter your username: ";
getline(std::cin, entereduser);
if (system("CLS")) system("clear");
string enteredpassword;
std::cout<< "Please enter your password (8-16 characters): ";
cin >> enteredpassword;
cout<<endl;
if (system("CLS")) system("clear");
User hello(entereduser,enteredpassword);
std::cout << "Hello " << hello.getusername() << "!" <<std::endl;
cout<<endl;
while(true)
{
cout << "Enter 1 for Accounts or 2 for Loans or 3 to exit the program : ";
int choice = 0;
while(true)
{
if(cin >> choice && choice >= 1 && choice <= 3)
{
break;
}
cout << endl;
cin.clear();
cin.ignore(120,'\n');
cout << "Please choose a valid option: ";
}
cout << endl;
switch(choice)
{
case 1:
if (system("CLS")) system("clear");
start_program_Account();
break;
case 2:
if (system("CLS")) system("clear");
start_program_Loan();
cout << endl;
break;
case 3:
if (system("CLS")) system("clear");
cout << "Thankyou for using our program, we hope to see you soon" << endl;
break;
}
if(choice == 3)
{
break;
}
}
}
int main()
{
start_program();
return 0;
}