-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStatement.cpp
125 lines (101 loc) · 3.66 KB
/
Statement.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
#include "Statement.h"
#include "Card.h"
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <ctime>
using namespace std;
// âûïèñêà î ïîïîëíåíèè ñðåäñòâ êàðòî÷êè
void Statement::ToFileIn(Card& card, double money) {
ofstream record("statement.txt", ios::app);
time_t now = time(0);
tm* t = new tm;
localtime_s(t, &now);
if (record) {
record << "\t--------------------------------" << endl;
record << "\tÏîïîëíåíèå ñðåäñòâ:" << endl;
record << "\tÄàòà: ";
if (t->tm_mday < 10) record << "0" << t->tm_mday << ".";
else record << t->tm_mday << ".";
record << 1 + t->tm_mon << "." << 1900 + t->tm_year << endl;
record << "\tÂðåìÿ: ";
if (t->tm_hour < 10) record << "0" << t->tm_hour << ":";
else record << t->tm_hour << ":";
if (t->tm_min < 10) record << "0" << t->tm_min << ":";
else record << t->tm_min << ":";
if (t->tm_sec < 10) record << "0" << t->tm_sec << endl;
else record << t->tm_sec << endl;
record << "\tÍîìåð êàðòû: " << card.GetNumber() << endl;
record << "\tÑóììà îïåðàöèè: " << money << endl;
record << "\tÄîñòóïíûå ñðåäñòâà: " << card.GetBalance() << endl;
record << "\t--------------------------------" << endl;
}
record.close();
}
// âûïèñêà î ñíÿòèè ñðåäñòâ ñ êàðòî÷êè
void Statement::ToFileFrom(Card& card, double money) {
ofstream record("statement.txt", ios::app);
time_t now = time(0);
tm* t = new tm;
localtime_s(t, &now);
if (record) {
record << "\t--------------------------------" << endl;
record << "\tÑíÿòèå ñðåäñòâ:" << endl;
record << "\tÄàòà: ";
if (t->tm_mday < 10) record << "0" << t->tm_mday << ".";
else record << t->tm_mday << ".";
record << 1 + t->tm_mon << "." << 1900 + t->tm_year << endl;
record << "\tÂðåìÿ: ";
if (t->tm_hour < 10) record << "0" << t->tm_hour << ":";
else record << t->tm_hour << ":";
if (t->tm_min < 10) record << "0" << t->tm_min << ":";
else record << t->tm_min << ":";
if (t->tm_sec < 10) record << "0" << t->tm_sec << endl;
else record << t->tm_sec << endl;
record << "\tÍîìåð êàðòû : " << card.GetNumber() << endl;
record << "\tÑóììà îïåðàöèè: " << money << endl;
record << "\tÎñòàòîê ñðåäñòâ: " << card.GetBalance() << endl;
record << "\t--------------------------------" << endl;
}
record.close();
}
//âûïèñêà î ïîïîëíåíèè ñ÷åòà â áàíêå
void Statement::ToFileIn(Bankomat& bank, double money) {
ofstream record("statement.txt", ios::app);
time_t now = time(0);
tm* t = new tm;
localtime_s(t, &now);
if (record) {
record << "\t--------------------------------" << endl;
record << "\tÏîïîëíåíèå ñ÷åòà:" << endl;
record << "\tÄàòà: ";
if (t->tm_mday < 10) record << "0" << t->tm_mday << ".";
else record << t->tm_mday << ".";
record << 1 + t->tm_mon << "." << 1900 + t->tm_year << endl;
record << "\tÂðåìÿ: ";
if (t->tm_hour < 10) record << "0" << t->tm_hour << ":";
else record << t->tm_hour << ":";
if (t->tm_min < 10) record << "0" << t->tm_min << ":";
else record << t->tm_min << ":";
if (t->tm_sec < 10) record << "0" << t->tm_sec << endl;
else record << t->tm_sec << endl;
record << "\tÑ÷åò ïîëó÷àòåëÿ: " << bank.GetNumber() << endl;
record << "\tÑóììà îïåðàöèè: " << money << endl;
record << "\tÄîñòóïíûå ñðåäñòâà: " << bank.GetBalance() << endl;
record << "\t--------------------------------" << endl;
}
record.close();
}
// âûâîä âûïèñêè
void Statement::Print(Singleton* log) {
ifstream read("statement.txt");
if (read) {
while (!read.eof()) {
string str;
getline(read, str);
cout << str << endl;
}
}
read.close();
log->SingletonOperation("Ïðåäîñòàâëåíèå âûïèñêè", 1);
}