-
Notifications
You must be signed in to change notification settings - Fork 0
/
places.cpp
88 lines (72 loc) · 1.87 KB
/
places.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
#include "places.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// Constructor for Place
Place::Place(string type, double prix) : type(type), prix(prix) {}
// Display a place's details
void Place::afficher() const {
cout << "Type: " << type << endl;
cout << "Prix: " << prix << endl;
}
// Get the type of a place
string Place::getType() const {
return type;
}
// Get the price of a place
double Place::getPrix() const {
return prix;
}
// Constructor for StandardPlace
StandardPlace::StandardPlace(int numero) : Place("Standard", 10.0), numero(numero) {}
// Display a StandardPlace's details
void StandardPlace::afficher() const {
Place::afficher();
cout << "Numéro: " << numero << endl;
}
// Get the number of a StandardPlace
int StandardPlace::getNumero() const {
return numero;
}
// Constructor for VipPlace
VipPlace::VipPlace(int numero) : Place("VIP", 20.0), numero(numero) {}
// Display a VipPlace's details
void VipPlace::afficher() const {
Place::afficher();
cout << "Numéro: " << numero << endl;
}
// Get the number of a VipPlace
int VipPlace::getNumero() const {
return numero;
}
// GestionPlaces implementation
class GestionPlaces {
public:
// Add a place
void ajouterPlace(Place* place) {
places.push_back(place);
}
// Get the list of places
const vector<Place*>& getPlaces() const {
return places;
}
// Search for a place (example: search by type)
Place* rechercherPlace(const string& type) const {
for (Place* place : places) {
if (place->getType() == type) {
return place;
}
}
return nullptr;
}
// Display all places
void afficherPlaces() const {
for (Place* place : places) {
place->afficher();
cout << endl;
}
}
private:
vector<Place*> places;
};