-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBooks.cpp
164 lines (125 loc) · 3.81 KB
/
Books.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
#include "lib.h"
#include "Books.h"
using namespace std;
Books::Books()
{
cout << "Constructor Books without attributes was called." << endl;
}
Books::~Books()
{
cout << "Destructor Books was called." << endl;
}
Books::Books(const Books& Books_copy)
{
name = Books_copy.name;
author = Books_copy.author;
yearin = Books_copy.yearin;
annotation = Books_copy.annotation;
genre = Books_copy.genre;
volume = Books_copy.volume;
cost = Books_copy.cost;
}
Books::Books(string name)
{
this->name = name;
}
string Books::get_name() const { return name; }
void Books::set_name(string name_ch) { name = name_ch; }
string Books::get_author() const { return author; }
void Books::set_author(string author_ch) { author = author_ch; }
string Books::get_yearin() const { return yearin; }
void Books::set_yearin(string yearin_ch) { yearin = yearin_ch; }
string Books::get_annotation() const { return annotation; }
void Books::set_annotation(string annotation_ch) { annotation = annotation_ch; }
string Books::get_genre() const { return genre; }
void Books::set_genre(string genre_ch) { genre = genre_ch; }
string Books::get_volume() const { return volume; }
void Books::set_volume(string volume_ch) { volume = volume_ch; }
string Books::get_cost() const { return cost; }
void Books::set_cost(string cost_ch) { cost = cost_ch; }
bool Books::SameCost(string SC_ch) {
if (SC_ch == (this->get_cost()))
return true;
else return false;
}
void Books::show()
{
setlocale(LC_ALL, "Russian");
cout << "------------------------------------" << endl;
cout << "Ïðåäìåò: Êíèãà" << endl;
cout << "Íàçâàíèå: " << name << endl;
cout << "Àâòîð: " << author << endl;
cout << "Ãîä âûïóñêà: " << yearin << endl;
cout << "Àííîòàöèÿ: " << annotation << endl;
cout << "Æàíð: " << genre << endl;
cout << "Êîë-âî ñòðàíèö: " << volume << endl;
cout << "Ñòîèìîñòü: " << cost << endl;
cout << "------------------------------------" << endl;
}
void Books::rewrite()
{
setlocale(LC_ALL, "Russian");
cout << "------------------------------------" << endl;
cin.ignore(32767, '\n');
cout << "Ïðåäìåò: Êíèãè" << endl;
cout << "Ââåäèòå íîâîå íàçâàíèå: ";
getline(cin, name);
cout << "Ââåäèòå íîâîãî àâòîðà: ";
getline(cin, author);
cout << "Ââåäèòå íîâûé ãîä âûïóñêà: ";
getline(cin, yearin);
cout << "Ââåäèòå íîâóþ àííîòàöèþ: ";
getline(cin, annotation);
cout << "Ââåäèòå íîâûé æàíð: ";
getline(cin, genre);
cout << "Ââåäèòå êîë-âî ñòðàíèö: ";
getline(cin, volume);
cout << "Ââåäèòå íîâóþ ñòîèìîñòü: ";
getline(cin, cost);
cout << "------------------------------------" << endl;
}
void Books::saving()
{
setlocale(LC_ALL, "Russian");
ofstream outfile;
string initfile = "bibliary.txt";
outfile.open(initfile, ios_base::app);
if (!outfile)
{
throw "Îøèáêà!";
system("pause");
exit(1);
}
outfile << 1 << endl << name << endl << author << endl << yearin << endl << annotation << endl << genre << endl << volume << endl << cost << endl;
outfile.close();
}
void Books::redact_str(int num_str, string red_str)
{
setlocale(LC_ALL, "Russian");
switch (num_str)
{
case 1:
this->name = red_str;
break;
case 2:
break;
case 3:
this->yearin = red_str;
break;
case 4:
this->annotation = red_str;
break;
case 5:
this->genre = red_str;
break;
case 6:
this->volume = red_str;
break;
case 7:
this->cost = red_str;
break;
default:
throw "Îøèáêà ïóíêòà ìåíþ!";
break;
}
}