-
Notifications
You must be signed in to change notification settings - Fork 2
/
TKTietKiem.cpp
119 lines (104 loc) · 2.67 KB
/
TKTietKiem.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
#include "TKTietKiem.h"
TKTietKiem::TKTietKiem()
{
this->tienGui = 0;
this->laiSuat = 0;
this->kiHan = 0;
this->soThangDaGui = 0;
this->ngayGui = "chua biet";
this->daTatToan = false;
}
TKTietKiem::TKTietKiem(int thoiHan, double laiSuat, double tienGui,int soThangDaGui,string ngayGui)
{
this->kiHan = thoiHan;
this->laiSuat = laiSuat;
this->tienGui = tienGui;
this->soThangDaGui = soThangDaGui;
this->ngayGui = ngayGui;
this->daTatToan = false;
int ngay = stoi(this->ngayGui.substr(0, 2));
int thang = stoi(this->ngayGui.substr(3, 2));
int nam = stoi(this->ngayGui.substr(6, 4));
for (int i = 0; i < this->kiHan; i++) {
thang += 1;
if (thang > 12) {
thang = 1;
nam += 1;
}
}
this->ngayDaoHan = to_string(ngay) + "/" + to_string(thang) + '/' + to_string(nam);
if (this->ngayDaoHan[2] != '/') {
this->ngayDaoHan = '0' + this->ngayDaoHan;
}
if (this->ngayDaoHan[5] != '/') {
this->ngayDaoHan.insert(3, "0");
}
}
void TKTietKiem::ganTienGui(double tienGui)
{
this->tienGui = tienGui;
}
void TKTietKiem::ganLaiSuat(double laiSuat)
{
this->laiSuat = laiSuat;
}
void TKTietKiem::capNhatSoThangDaGui()
{
if (this->daTatToan==false) {
this->soThangDaGui += 1;
}
}
void TKTietKiem::capNhatTinhTrang()
{
this->daTatToan = true;
}
bool TKTietKiem::kiemTraTinhTrang()
{
return this->daTatToan;
}
double TKTietKiem::layTienGui()
{
return this->tienGui;
}
int TKTietKiem::layKiHan()
{
return this->kiHan;
}
int TKTietKiem::laySoThangDaGui()
{
return this->soThangDaGui;
}
string TKTietKiem::layNgayGui()
{
return this->ngayGui;
}
void TKTietKiem::xuatThongTin()
{
cout << "Tien gui: " << this->tienGui << " trieu vnd" << endl;
cout << "Ki han: " << this->kiHan << endl;
cout << "Lai suat (%/Tong tien): " << this->laiSuat*100 << endl;
cout << "Ngay gui: " << this->ngayGui << endl;
cout << "So thang da gui: " << this->laySoThangDaGui() << endl;
cout << "Ngay dao han: " << this->ngayDaoHan << endl;
cout << "Tong tien sau khi tat toan: " << this->tattoanTKTietKiem() << " trieu" << endl;
}
void TKTietKiem::ghiFile(ostream& os)
{
double tien = 0;
string tatToan = "";
if (this->daTatToan == true) {
tien = this->tattoanTKTietKiem();
tatToan = "Da tat toan";
}
else {
tien = this->tienGui;
tatToan = "Chua tat toan";
}
os << this->ngayGui << "," << this->ngayDaoHan << "," << this->tienGui << "," << this->laiSuat*100 << "," << this->kiHan << "," << this->soThangDaGui << "," << tatToan << "," << tien << endl;
}
double TKTietKiem::tattoanTKTietKiem()
{
return this->tienGui * this->laiSuat + this->tienGui;
}
TKTietKiem::~TKTietKiem(){
}