-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.cpp
87 lines (79 loc) · 2.15 KB
/
Card.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
#include <iostream>
#include "Card.h"
//ęîíńňđóęňîđ ----- ââîä äŕííűő î ęŕđňî÷ęĺ čç ôŕéëčęŕ
Card::Card(int n) {
int chosen = n;
string card_number = "no";
string card_holder = "no";
string card_data = "no";
int card_pin = 0;
int card_cvv = 0;
double card_balance;
string empty;
int k = 0, l = chosen - 1;
//cout << l;
//system("pause");
//cout << chosen << endl;
ifstream from_card("card.txt");
if (from_card) {
from_card >> k;
getline(from_card, empty);
for (int i = 0; i < k; i++) {
if (i == l) {
getline(from_card, card_number);
SetNumber(card_number);
getline(from_card, card_data);
SetCardData(card_data);
getline(from_card, card_holder);
SetHolder(card_holder);
from_card >> card_pin;
getline(from_card, empty);
SetCardPin(card_pin);
from_card >> card_cvv;
SetCardCvv(card_cvv);
getline(from_card, empty);
from_card >> card_balance;
SetBalance(card_balance);
getline(from_card, empty);
break;
}
else {
getline(from_card, card_number);
getline(from_card, card_data);
getline(from_card, card_holder);
from_card >> card_pin;
getline(from_card, empty);
from_card >> card_cvv;
getline(from_card, empty);
from_card >> card_balance;
getline(from_card, empty);
}
}
}
from_card.close();
}
// âűâîä äŕííűő î ęŕđňî÷ęĺ
void Card::Print(Singleton* log) {
cout << "\t-------------------------" << endl;
cout << "\t Äŕííűĺ ęŕđňű: " << endl;
cout << "\t-------------------------" << endl;
cout << "\tÍîěĺđ ęŕđňî÷ęč: ";// << GetNumber() << endl;
Secret(GetNumber());
cout << "\tÂëŕäĺëĺö ęŕđňî÷ęč: " << GetHolder() << endl;
cout << "\tŃđîę ýęńďëóňŕöčč: " << GetCardData() << endl;
cout << "\tÄîńňóďíűĺ ńđĺäńňâŕ: " << GetBalance() << endl;
log->SingletonOperation("Äŕííűĺ áŕíęîâńęîé ęŕđňî÷ęč", 1);
}
void Card::Secret(string s) {
int space = 0;
for (int i = 0; i < s.size(); i++) {
if (space == 3) {
cout << s[i] << s[i + 1] << s[i + 2] << s[i + 3] << endl;
break;
}
else {
if (s[i] == ' ') { cout << " "; space++; }
else cout << "*";
}
}
}