-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathressource.cpp
116 lines (94 loc) · 1.97 KB
/
ressource.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
#include "include.h"
string ressource::getTitre() const
{
return titre;
}
void ressource::setTitre(const string &value)
{
titre = value;
}
string ressource::getAuteur() const
{
return auteur;
}
void ressource::setAuteur(const string &value)
{
auteur = value;
}
type_ressource ressource::getType() const
{
return type;
}
void ressource::setType(const type_ressource &value)
{
type = value;
}
int ressource::getId() const
{
return id;
}
void ressource::setId(int value)
{
id = value;
}
etat ressource::getEtat_actuel() const
{
return etat_actuel;
}
void ressource::setEtat_actuel(const etat &value)
{
etat_actuel = value;
}
ressource::ressource()
{
}
ressource::~ressource()
{
}
ressource::ressource(type_ressource _type, int _id, std::string _titre, std::string _auteur, etat etate):
id(_id),titre(_titre),auteur(_auteur), type(_type), etat_actuel(etate)
{
}
void ressource::save(std::ofstream &infile) const
{
infile<<enum_string_type(type)<<endl
<<titre<<endl
<<auteur<<endl
<<enum_string_etat(etat_actuel)<<endl;
}
void ressource::load(std::istream &file)
{
string tampon;
cout << "Quel est le titre de cette oeuvre?" << endl;
do{
getline( file, tampon);
}while(tampon.size()==0);
setTitre(tampon);
cout << "Qui est l'auteur de cette oeuvre?" << endl;
do{
getline( file, tampon);
}while(tampon.size()==0);
setAuteur(tampon);
//do{
if (file!=cin)
{
getline(file, tampon);
//}while(tampon.size()==0);
setEtat_actuel(enum_string_etat(tampon));
}
}
void ressource::show() const
{
cout<<"Type: " << enum_string_type(type)<<endl
<<"Titre: "<<titre<<endl
<<"Auteur: " << auteur << endl
<< "Etat: "<< enum_string_etat(etat_actuel) << endl;
}
bool ressource::search(std::string str) const
{
if (titre.find(str)!=string::npos)
return true;
if (auteur.find(str)!=string::npos)
return true;
return false;
}