-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBank.cpp
173 lines (157 loc) · 3.64 KB
/
Bank.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
#include "Bank.h"
#include <fstream>
#include <string>
#include "Card.h"
using namespace std;
// ęîíńňđóęňîđ
Bank::Bank() {
//int chosen = GetChosen();
chosen = 1111;
//cout << chosen;
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 << chosen;
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;
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();
}
//ăĺňňĺđű č ńĺňňĺđű
string Bank::GetNumber() {
return number;
}
string Bank::GetHolder() {
return holder;
}
string Bank::GetCardData() {
return card_data;
}
int Bank::GetCardPin() {
return card_pin;
}
double Bank::GetBalance() {
return balance;
}
int Bank::GetCardCvv() {
return card_cvv;
}
int Bank::GetCardChosen() {
return chosen;
}
void Bank::SetNumber(string number) {
this->number = number;
}
void Bank::SetHolder(string holder) {
this->holder = holder;
}
void Bank::SetCardPin(int pin) {
this->card_pin = pin;
}
void Bank::SetCardData(string data) {
this->card_data = data;
}
void Bank::SetBalance(double balance) {
this->balance = balance;
}
void Bank::SetCardChosen(int n) {
this->chosen = n;
}
void Bank::SetCardCvv(int n) {
this->card_cvv = n;
}
// ęîďčđîâŕíčĺ äŕííűő î ęŕđňî÷ęĺ
void Bank::CopyData() {
ifstream from_card("card.txt");
ofstream new_card("newcard.txt");
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;
if (from_card) {
if (new_card) {
from_card >> k;
getline(from_card, empty);
new_card << k << endl;
for (int i = 0; i < k; i++) {
getline(from_card, card_number);
new_card << card_number << endl;
getline(from_card, card_data);
new_card << card_data << endl;
getline(from_card, card_holder);
new_card << card_holder << endl;
from_card >> card_pin;
new_card << card_pin << endl;
getline(from_card, empty);
from_card >> card_cvv;
new_card << card_cvv << endl;
getline(from_card, empty);
from_card >> card_balance;
new_card << card_balance << endl;
getline(from_card, empty);
}
}
}
from_card.close();
new_card.close();
}
// ęîďčđîâŕíčĺ äŕííűő î ń÷ĺňĺ â áŕíęĺ
void Bank::CopyAccount() {
ifstream from_account("ac.txt");
ofstream new_account("newac.txt");
if (from_account) {
if (new_account) {
string ac_num, ac_hol;
int na;
getline(from_account, ac_num);
new_account << ac_num << endl;
getline(from_account, ac_hol);
new_account << ac_hol << endl;
from_account >> na;
new_account << na << endl;
}
}
from_account.close();
new_account.close();
}