-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourse.cpp
128 lines (106 loc) · 2.17 KB
/
course.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
#include <iostream>
#include "course.hpp"
#include "libraries/json.hpp"
Course::Course()
{
}
Course::~Course()
{
}
void Course::print()
{
cout << "===================" << endl;
cout.setf(ios::fixed);
cout.precision(2);
cout << currency << endl;
cout << state << endl;
cout << code << endl;
cout << "1 " + code + " = " << rate << endl;
cout << "===================" << endl;
}
void Course::read_from_file(ifstream& fp)
{
string trash;
getline(fp, trash);
getline(fp, currency);
getline(fp, state);
getline(fp, code);
getline(fp, subunit);
fp >> fraction;
fp >> rate;
}
void Course::read_from_console()
{
string trash;
getline(cin, trash);
cout << "Введите название валюты:" << endl;
getline(cin, currency);
cout << "Введите государство:" << endl;
getline(cin, state);
cout << "Введите код валюты:" << endl;
getline(cin, code);
cout << "Введите название разменной валюты:" << endl;
getline(cin, subunit);
cout << "Сколько разменной валюты в основной:" << endl;
cin >> fraction;
cout << "Введите курс валюты к российскому рублю:" << endl;
cin >> rate;
getline(cin, trash);
}
void Course::write_to_file(ofstream& fp)
{
fp << currency << endl;
fp << state << endl;
fp << code << endl;
fp << subunit << endl;
fp << fraction << endl;
fp << rate << endl;
}
string Course::get_currency()
{
return currency;
}
string Course::get_state()
{
return state;
}
string Course::get_subunit()
{
return subunit;
}
string Course::get_code()
{
return code;
}
int Course::get_fraction()
{
return fraction;
}
double Course::get_rate()
{
return rate;
}
void Course::set_currency(string cur)
{
currency = cur;
}
void Course::set_state(string stat)
{
state = stat;
}
void Course::set_code(string cod)
{
code = cod;
}
void Course::set_subunit(string sub)
{
subunit = sub;
}
void Course::set_fraction(int frac)
{
fraction = frac;
}
void Course::set_rate(double rat)
{
rate = rat;
}