-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainScreen.cpp
More file actions
112 lines (92 loc) · 2.57 KB
/
Copy pathMainScreen.cpp
File metadata and controls
112 lines (92 loc) · 2.57 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
#include <iostream>
#include "MainScreen.h"
#include "CardSessions.h"
#include "Exception.h"
#include "Singleton.h"
#include "Chosen.h"
#include <string>
using namespace std;
// çàñòâàêà ãëàâíîãî ýêðàíà
MainScreen::MainScreen(Singleton* log) {
log->SingletonOperation("Ïðèíÿòèå êàðòî÷êè", 1);
cout << endl << endl << endl << endl << endl << endl << endl;
cout << "\t\t\t\t\t-----------------------" << endl;
cout << "\t\t\t\t\t Âñòàâüòå êàðòó!" << endl;
cout << "\t\t\t\t\t-----------------------" << endl << endl << endl << endl;
system("pause");
system("cls");
}
bool MainScreen::CheckStr(char* s, int old) {
char p[33] = { 'à','á','â','ã','ä','å','¸','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','÷','ø','ù','ú','û','ü','ý','ÿ' };
bool flag = false;
int i = 0;
if (sizeof(s) >= 5) flag = 0;
else {
while (s[i] != '\n') {
if (s[i] == p[i]) {
flag = false;
break;
}
i++;
}
if (old == atoi(s)) flag = true;
}
return flag;
}
// ïðîâåðêà íà ïðàâèëüíîñòü ââåäåííîãî ïèí-êîäà êàðòî÷êè
bool MainScreen::CheckPin(Singleton* log, int k, Card& card) {
system("cls");
//Card card(k);
int old = card.GetCardPin();
cout << old << endl;
//system("pause");
bool flag = 0;
bool next;
for (int i = 3; i >= 1; i--)
{
//int new_pin;
char new_p[6];
cout << endl << endl << endl << endl << endl << endl << endl << endl << "\t\t\t\t\tÂâåäèòå ïèí-êîä: ";
//cin >> new_pin;
//getline(cin, new_p);
//system("pause");
cin.ignore();
cin.getline(new_p, 6, '\n');
cout << endl << endl;
bool flag_new = CheckStr(new_p, old);
try {
if (atoi(new_p) > 9999 || flag_new == false) {
throw Exception("Íåäîïóñòèìûé ââîä ïèí-êîä", "Ââîä ïèí-êîä");
}
}
catch (Exception& exception) {
cerr << exception.what() << endl;
}
if (old == atoi(new_p)) {
log->SingletonOperation("Ïðîâåðêà ïèí-êîä", 1);
flag = true;
next = true;
system("cls");
break;
}
else {
flag = 0;
if (i - 1 == 0) break;
else {
system("cls");
log->SingletonOperation("Ïðîâåðêà ïèí-êîä - ïîïûòêà", 0);
cout << endl << endl << "\t\t\tÍåâåðíûé ïèí-êîä! Ïîïðîáóéòå åù¸ ðàç! Îñòàëîñü ïîïûòîê: " << i - 1 << endl;
}
}
}
if (flag == 0) {
system("cls");
log->SingletonOperation("Ïðîâåðêà ïèí-êîä", 0);
cout << endl << endl << endl << endl << endl << endl << endl << endl << "\t\t\t\t\tÍåâåðíûé ïèí-êîä. Ïîïðîáóéòå ïîçæå!" << endl;
next = false;
}
cout << endl;
return next;
system("pause");
system("cls");
}