-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlivre.cpp
More file actions
118 lines (97 loc) · 2.42 KB
/
Copy pathlivre.cpp
File metadata and controls
118 lines (97 loc) · 2.42 KB
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
#include "include.h"
std::string livre::getResume() const
{
return resume;
}
void livre::setResume(const std::string &value)
{
resume = value;
}
std::string livre::getCollection() const
{
return collection;
}
void livre::setCollection(const std::string &value)
{
collection = value;
}
int livre::getAnnee_publication() const
{
return annee_publication;
}
void livre::setAnnee_publication(int value)
{
annee_publication = value;
}
int livre::getNb_pages() const
{
return nb_pages;
}
void livre::setNb_pages(int value)
{
nb_pages = value;
}
livre::livre()
{
}
livre::~livre()
{
}
livre::livre(type_ressource _type, int _id, std::string _titre, std::string _auteur, int _annee_publi, int _nb_page, std::string _collection, std::string _resume, etat _etat) :
ressource(_type, _id, _titre, _auteur, _etat), //ressource
annee_publication(_annee_publi), nb_pages(_nb_page), collection(_collection), resume(_resume) //livre
{
}
void livre::show() const
{
ressource::show();
cout << "Annee de publication: " << annee_publication << endl
<< "Nombre de pages: " << nb_pages << endl
<<"Collection: "<<collection<<endl
<<"Resume: "<<resume<<endl;
}
void livre::save(std::ofstream &infile) const
{
ressource::save(infile);
infile<< annee_publication << endl
<<nb_pages<<endl
<<collection<<endl
<<resume<<endl;
}
void livre::load(std::istream &file)
{
string tampon;
ressource::load(file);
cout << "En quel annee ce livre a-t-il ete publie?" << endl;
do{
getline( file, tampon);
}while(tampon.size()==0);
setAnnee_publication(atoi(tampon.c_str()));
cout << "Combien y a-t-il de pages dans ce livre?" << endl;
do{
getline( file, tampon);
}while(tampon.size()==0);
setNb_pages(atoi(tampon.c_str()));
cout << "Dans quelle collection ce livre a-t-il ete publie?" << endl;
do{
getline( file, tampon);
}while(tampon.size()==0);
setCollection(tampon);
cout << "Avez-vous un resume de ce livre?" << endl;
do{
getline( file, tampon);
}while(tampon.size()==0);
setResume(tampon);
}
bool livre::search(std::string str) const
{
if (ressource::search(str))
return true;
if (annee_publication==atoi(str.c_str()))
return true;
if (collection.find(str)!=string::npos)
return true;
if (resume.find(str)!=string::npos)
return true;
return false;
}