-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextbook.cpp
154 lines (128 loc) · 3.66 KB
/
Textbook.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
#include "lib.h"
using namespace std;
Textbooks::Textbooks()
{
cout << "Constructor Textbook without attributes was called." << endl;
}
Textbooks::~Textbooks()
{
cout << "Destructor Textbook was called." << endl;
}
Textbooks::Textbooks(const Textbooks& Textbook_copy)
{
name = Textbook_copy.name;
author = Textbook_copy.author;
yearin = Textbook_copy.yearin;
WhStudy = Textbook_copy.WhStudy;
Ystudy = Textbook_copy.Ystudy;
volume = Textbook_copy.volume;
cost = Textbook_copy.cost;
}
Textbooks::Textbooks(string name)
{
this->name = name;
}
string Textbooks::get_name() const { return name; }
void Textbooks::set_name(string name_ch) { name = name_ch; }
string Textbooks::get_author() const { return author; }
void Textbooks::set_author(string author_ch) { author = author_ch; }
string Textbooks::get_yearin() const { return yearin; }
void Textbooks::set_yearin(string yearin_ch) { yearin = yearin_ch; }
string Textbooks::get_WhStudy() const { return WhStudy; }
void Textbooks::set_WhStudy(string WhStudy_ch) { WhStudy = WhStudy_ch; }
string Textbooks::get_Ystudy() const { return Ystudy; }
void Textbooks::set_Ystudy(string Ystudy_ch) { Ystudy = Ystudy_ch; }
string Textbooks::get_volume() const { return volume; }
void Textbooks::set_volume(string volume_ch) { volume = volume_ch; }
string Textbooks::get_cost() const { return cost; }
void Textbooks::set_cost(string cost_ch) { cost = cost_ch; }
bool Textbooks::SameCost(string SC_ch) {
if (SC_ch == (this->get_cost()))
return true;
else return false;
}
void Textbooks::show()
{
setlocale(LC_ALL, "Russian");
cout << "------------------------------------" << endl;
cout << "Ïðåäìåíò: Ó÷åáíèê" << endl;
cout << "Íàçâàíèå: " << name << endl;
cout << "Àâòîð: " << author << endl;
cout << "Ãîä âûïóñêà: " << yearin << endl;
cout << "Äëÿ êàêîãî ó÷ çàâåäåíèÿ:" << WhStudy << endl;
cout << "Ãîä îáó÷åíèÿ: " << Ystudy << endl;
cout << "Êîë-âî ñòðàíèö: " << volume << endl;
cout << "Ñòîèìîñòü: " << cost << endl;
cout << "------------------------------------" << endl;
}
void Textbooks::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, WhStudy);
cout << "Ââåäèòå ãîä îáó÷åíèÿ: ";
getline(cin, Ystudy);
cout << "Ââåäèòå êîë-âî ñòðàíèö: ";
getline(cin, volume);
cout << "Ââåäèòå íîâóþ ñòîèìîñòü: ";
getline(cin, cost);
cout << "------------------------------------" << endl;
}
void Textbooks::saving()
{
setlocale(LC_ALL, "Russian");
ofstream outfile;
string initfile = "bibliary.txt";
outfile.open(initfile, ios_base::app);
if (!outfile)
{
throw "Îøèáêà ôàéëà";
system("pause");
exit(1);
}
else
{
outfile << 2 << endl << name << endl << author << endl << yearin << endl << WhStudy << endl << Ystudy << endl << volume << endl << cost << endl;
outfile.close();
}
}
void Textbooks::redact_str(int num_str, string red_str)
{
setlocale(LC_ALL, "Russian");
switch (num_str)
{
case 1:
this->name = red_str;
break;
case 2:
this->author = red_str;
break;
case 3:
this->yearin = red_str;
break;
case 4:
this->WhStudy = red_str;
break;
case 5:
this->Ystudy = red_str;
break;
case 6:
this->volume = red_str;
break;
case 7:
this->cost = red_str;
break;
default:
throw "Íåâåðíûé íîìåð ìåíþ";
break;
}
}