-
Notifications
You must be signed in to change notification settings - Fork 0
/
mediatheque.cpp
178 lines (171 loc) · 4.46 KB
/
mediatheque.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include <string>
#include <vector>
#include <time.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>
using namespace std;
#include "mediatheque.h"
Exemplaire::Exemplaire(Oeuvre* O)
{
oeuvre = O;
pret = false;
}
void Exemplaire::Emprunter_exemplaire(Adherent* A)
{
adherent = A;
pret = true;
time_t now;
time(&now);
date_pret = now;
//A->Emprunter_exemplaire(&);
}
void Exemplaire::set_datepret(time_t t)
{
date_pret = t;
}
string Exemplaire::Afficher_exemplaire()
{
string Afficher_exemplaire;
Afficher_exemplaire += "Oeuvre de l'exemplaire : ";
Afficher_exemplaire += oeuvre->Afficher_oeuvre();
Afficher_exemplaire += "\n";
if(pret == true)
{
Afficher_exemplaire += "Exemplaire emprunte par : \n";
Afficher_exemplaire += adherent->nom;
Afficher_exemplaire += " ";
Afficher_exemplaire += adherent->pnom;
Afficher_exemplaire += "\nCet emprunt date du : ";
Afficher_exemplaire += ctime(&date_pret);
}
else
{
Afficher_exemplaire += "Cet exemplaire n'est pas encore emprunte \n";
}
return Afficher_exemplaire;
}
Adherent::Adherent(string n,string pn,string adr,int numt,string mail)
{
nom = n;
pnom = pn;
adresse = adr;
num_tel = numt;
email = mail;
}
void Adherent::Emprunter_exemplaire(Exemplaire* exemp)
{
ex_emp.push_back(exemp);
}
void Adherent::Supprimer_exemplaire(Exemplaire* exemp)
{
vector<Exemplaire*>::iterator it(find(ex_emp.begin(),ex_emp.end(),exemp));
if(it != ex_emp.end())
{
ex_emp.erase(it);
}
}
string Adherent::Afficher_adherent()
{
string Afficher_adherent;
Afficher_adherent += "Nom : ";
Afficher_adherent += nom;
Afficher_adherent += "\nPrenom : ";
Afficher_adherent += pnom;
Afficher_adherent += "\nAdresse : ";
Afficher_adherent += adresse;
Afficher_adherent += "\nNumero de telephone : ";
Afficher_adherent += num_tel;
Afficher_adherent += "\nEmail : ";
Afficher_adherent += email;
if(ex_emp.size() > 0)
{
Afficher_adherent += "\nExemplaires empruntes : \n";
for(int i=0;i<ex_emp.size();i++)
{
Afficher_adherent += ex_emp[i]->Afficher_exemplaire();
}
}
Afficher_adherent += "\n";
return Afficher_adherent;
}
Oeuvre::Oeuvre(string t,string a,string r,int nbex)
{
titre = t;
auteur = a;
resume = r;
nb_exemplaires = nbex;
}
string Oeuvre::Afficher_oeuvre()
{
string Afficher_oeuvre;
Afficher_oeuvre += "Titre de l'oeuvre : ";
Afficher_oeuvre += titre;
Afficher_oeuvre += "\n";
Afficher_oeuvre += "Auteur de l'oeuvre : ";
Afficher_oeuvre += auteur;
Afficher_oeuvre += "\n";
//cout << "Type de l'oeuvre : " << type_oeuvre << endl;
Afficher_oeuvre += "Resume de l'oeuvre : ";
Afficher_oeuvre += resume;
Afficher_oeuvre += "\n";
Afficher_oeuvre += "Nombre total d'exemplaires : ";
Afficher_oeuvre += nb_exemplaires;
Afficher_oeuvre += "\n";
return Afficher_oeuvre;
}
Mediatheque::Mediatheque(string t)
{
nom_mediatheque = t;
}
void Mediatheque::Ajouter_adherent(Adherent* a)
{
Adherents.push_back(a);
}
void Mediatheque::Supprimer_adherent(Adherent* a)
{
vector<Adherent*>::iterator it(find(Adherents.begin(),Adherents.end(),a));
if(it != Adherents.end())
{
Adherents.erase(it);
}
}
void Mediatheque::Ajouter_oeuvre(Oeuvre* O)
{
Oeuvres.push_back(O);
}
void Mediatheque::Supprimer_oeuvre(Oeuvre* O)
{
vector<Oeuvre*>::iterator it(find(Oeuvres.begin(),Oeuvres.end(),O));
if(it != Oeuvres.end())
{
Oeuvres.erase(it);
}
}
string Mediatheque::Afficher_mediatheque()
{
string Afficher;
Afficher += "Nom mediatheque : ";
Afficher += nom_mediatheque;
Afficher += "\n\n";
if(Oeuvres.size() > 0)
{
Afficher += "Oeuvres de la mediatheque : \n";
for(int i = 0;i < Oeuvres.size();i++)
{
Afficher += Oeuvres[i]->Afficher_oeuvre();
Afficher += "\n";
}
}
if(Adherents.size() > 0)
{
Afficher += "Adherents de la mediatheque : \n";
for(int j = 0;j < Adherents.size();j++)
{
Afficher += Adherents[j]->Afficher_adherent();
Afficher += "\n";
}
}
return Afficher;
}