-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathders1.cpp
More file actions
310 lines (279 loc) · 6.58 KB
/
ders1.cpp
File metadata and controls
310 lines (279 loc) · 6.58 KB
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
using namespace std;
void kayıt() {
int sıra = 0;
ifstream d("kayıt.txt");
string sır;
if (d.is_open()) {
while (getline(d, sır)) {
sıra++;
}
}
string ad;
string tc;
cout << "Lütfen ilk önce adını griin:\n" << endl;
cin >> ad;
cout << "Tc numaranızı girin:\t" << endl;
cin >> tc;
while (tc.length() != 2) {
cout << "Tc geçersiz yeniden girin :\t" << endl;
cin >> tc;
}
ofstream x("kayıt.txt", ios::app);
if (x.is_open()) {
x << "\n" << sıra << ad << tc;
}
x.close();
ofstream y("money.txt", ios::app);
if (y.is_open()) {
y << "\n" << sıra << ":" << "0" << "TL";
}
y.close();
}
void gos() {
ifstream p("kayıt.txt");
string de;
if (p.is_open()) {
while (getline(p, de)) {
cout << de << endl;
}
}
}
bool regıs() {
string kullan, password,tccc;
cout << "-----------------------------------------"<<endl;
cout << "Maybe Yapının Özel Banka Uygulamasına Hoş Geldiniz"<<endl;
cout << "Lütfen Kayıt etmek istediğiniz kullanıcı adını girin" << endl;
cin >> kullan;
cout << "Lütfen Kayıt etmek istediğiniz şifreyi girin" << endl;
cin >> password;
cout << "Lütfen Kayıt etmek istediğiniz tc girin" << endl;
cin >> tccc;
while (2 != tccc.length()) {
cout << "lütfen tc 2 haneli olacakşekilde yapın" << endl;
cin >> tccc;
}
int sıra = 0;
ifstream d("kayıt.txt");
string sır;
while (getline(d, sır)) {
sıra++;
}
d.close();
ofstream x("kayıt.txt", ios::app);
if (x.is_open()) {
x << sıra << kullan << tccc << "\n";
}
x.close();
ofstream ı("money.txt", ios::app);
if (ı.is_open()) {
ı << sıra << ":0TL" << "\n";
}
ı.close();
ofstream o("log.txt", ios::app);
if (o.is_open()) {
o << sıra << "." << kullan <<":" << password << "\n";
}
o.close();
return true;
}
void money() {
int ıd;
int sıra = 0;
int kayıt = 0;
cout << "Görmek istediğinz id girin \t";
cin >> ıd;
ifstream r("kayıt.txt");
string sıraa;
if (r.is_open()) {
while (getline(r, sıraa)) {
kayıt++;
}
}
while (ıd >= kayıt) {
cout << "hatalı griiş ıd doğru griin";
cin >> ıd;
}
ifstream d("money.txt");
string sır;
if (d.is_open()) {
while (getline(d, sır)) {
if (sıra == ıd) {
cout << sır;
break;
}
else
{
sıra++;
}
}
}
}
void para() {
int id;
int toplamKullanici = 0;
cout << "Lütfen ID girin: ";
cin >> id;
ifstream kayit("kayıt.txt");
string satir;
while (getline(kayit, satir)) {
toplamKullanici++;
}
kayit.close();
while (id >= toplamKullanici) {
cout << "Geçersiz ID! Yeniden girin: ";
cin >> id;
}
ifstream paraDosya("money.txt");
vector<string> tumSatirlar;
while (getline(paraDosya, satir)) {
tumSatirlar.push_back(satir);
}
paraDosya.close();
string paraSatiri = tumSatirlar[id];
size_t ikiNokta = paraSatiri.find(':');
string bakiyeStr = paraSatiri.substr(ikiNokta + 1);
size_t tlPoz = bakiyeStr.find("TL");
if (tlPoz != string::npos) {
bakiyeStr = bakiyeStr.substr(0, tlPoz);
}
float bakiye = stof(bakiyeStr);
int secim;
float miktar;
cout << "Mevcut bakiye: " << bakiye << " TL\n";
cout << "1 - Para Yatır\n2 - Para Çek\nSeçiminiz: ";
cin >> secim;
cout << "Miktar: ";
cin >> miktar;
if (secim == 1) {
bakiye += miktar;
}
else if (secim == 2) {
while (miktar > bakiye) {
cout << "Yetersiz bakiye!.Yeniden girin" << endl;
cin >> miktar;
}
bakiye -= miktar;
}
else {
cout << "Geçersiz işlem seçimi!" << endl;
return;
}
tumSatirlar[id] = to_string(id) + ":" + to_string((int)bakiye) + "TL";
ofstream yaz("money.txt", ios::trunc);
for (const auto& s : tumSatirlar) {
yaz << s << "\n";
}
yaz.close();
cout << "Yeni bakiye: " << bakiye << " TL" << endl;
}
string lo() {
vector<string> ve;
string kull, pass;
int sayma = 0;
cout << "Giriş yapmak için kullanıcı adını girin:\t";
cin >> kull;
cout << "Giriş yapmak için şifreyi girin:\t";
cin >> pass;
ifstream ope("log.txt");
string okuma;
while (getline(ope, okuma)) {
ve.push_back(okuma);
sayma++;
}
ope.close();
string verkull[100], verpass[100],verıd[100];
for (int y = 0; sayma > y; y++) {
string s = ve[y];
verıd[y] = ve[y].substr(0, ve[y].find('.'));
verkull[y] = ve[y].substr(ve[y].find('.')+1,ve[y].find(':')- ve[y].find('.')-1);
verpass[y] = ve[y].substr(ve[y].find(':')+1);
}
bool bulundu = false;
for (int i = 0; i < sayma; i++) {
if (kull == verkull[i]) {
while (pass != verpass[i]) {
cout << "şifreniz yanlış yeniden gir:\t";
cin >> pass;
}
bulundu = true;
break;
}
}
if (bulundu == true) {
return "true";
}
else {
return "false";
}
}
int main() {
setlocale(LC_ALL, "Turkish");
int mai;
cout << "----------------------------------"<<endl;
cout << "Login için : 1" << endl;
cout << "Kayıt için : 2" << endl;
cin >> mai;
switch (mai) {
case 1: {
if (lo() == "true") {
int secim;
do {
cout << "\n--- Menü ---\n";
cout << "1 - Yeni Kayıt\n";
cout << "2 - Kayıtları Göster\n";
cout << "3 - Bakiye Görüntüle (ID ile)\n";
cout << "4 - Para Yatır / Çek\n";
cout << "0 - Çıkış\n";
cout << "Seçiminiz: ";
cin >> secim;
switch (secim) {
case 1: kayıt(); break;
case 2: gos(); break;
case 3: money(); break;
case 4: para(); break;
case 0: cout << "Programdan çıkılıyor...\n"; break;
default: cout << "Geçersiz seçim! Lütfen tekrar deneyin.\n";
}
} while (secim != 0);
}
else {
cout << "kullanıcı adı şifre yanlış";
}
break;
}
case 2: {
if (regıs() == true) {
if (lo() == "true") {
int secim;
do {
cout << "\n--- Menü ---\n";
cout << "1 - Yeni Kayıt\n";
cout << "2 - Kayıtları Göster\n";
cout << "3 - Bakiye Görüntüle (ID ile)\n";
cout << "4 - Para Yatır / Çek\n";
cout << "0 - Çıkış\n";
cout << "Seçiminiz: ";
cin >> secim;
switch (secim) {
case 1: kayıt(); break;
case 2: gos(); break;
case 3: money(); break;
case 4: para(); break;
case 0: cout << "Programdan çıkılıyor...\n"; break;
default: cout << "Geçersiz seçim! Lütfen tekrar deneyin.\n";
}
} while (secim != 0);
}
else {
cout << "Kullanıcı adı şifre yanlış/Lütfen Yeniden Deneyin";
}
}
}
break;
}
return 0;
}