// ==============================
// Solution : Gestion des Salles de TP
// ==============================
#include <iostream>
#include <string>
using namespace std;
// Classe Personne
class Personne {
string nom;
string prenom;
public:
Personne(string n, string p) : nom(n), prenom(p) {}
string toString() const {
return prenom + " " + nom;
}
};
// Classe Enseignant
class Enseignant {
public:
string departement;
private:
Personne* identite;
public:
Enseignant(string nom, string prenom, string dep) : departement(dep) {
identite = new Personne(nom, prenom);
}
~Enseignant() {
delete identite;
}
string toString() const {
return identite->toString() + " (" + departement + ")";
}
};
// Classe SeanceTP
class SeanceTP {
public:
string matiere;
string groupe;
Enseignant* responsable;
private:
static int nbSeances;
public:
SeanceTP(string m, string g, Enseignant* r) : matiere(m), groupe(g),
responsable(r) {
nbSeances++;
}
~SeanceTP() {
delete responsable;
}
string toString() const {
return groupe + " " + matiere + "\n" + responsable->toString();
}
static int getNbSeances() {
return nbSeances;
}
bool operator==(const SeanceTP& other) const {
return this->matiere == [Link];
}
};
int SeanceTP::nbSeances = 0;
// Classe SalleTP
class SalleTP {
private:
int numero;
int nbPCs;
SeanceTP* emploiTemps[6][4];
public:
static const int capacite = 30;
SalleTP(int num) : numero(num), nbPCs(16) {
for (int i = 0; i < 6; ++i)
for (int j = 0; j < 4; ++j)
emploiTemps[i][j] = nullptr;
}
void affecterSeance(int jour, int creneau, SeanceTP* s) {
emploiTemps[jour][creneau] = s;
}
void affichEmploiTemps() const {
string jours[6] = {"Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi",
"Samedi"};
string creneaux[4] = {"8h–10h", "10h–12h", "14h–16h", "16h–18h"};
for (int i = 0; i < 6; ++i) {
for (int j = 0; j < 4; ++j) {
cout << jours[i] << " " << creneaux[j] << " : ";
if (emploiTemps[i][j] != nullptr)
cout << emploiTemps[i][j]->toString() << "\n";
else
cout << "Libre\n";
}
}
}
static void afficherCapacite() {
cout << "Capacité maximale d'une salle : " << capacite << " étudiants." <<
endl;
}
};
int main() {
// Étape 1 : Création d'enseignants responsables de deux séances identiques en
matière
Enseignant* prof1 = new Enseignant("Test", "Prof", "Info");
Enseignant* prof2 = new Enseignant("Demo", "Prof", "Info");
// Étape 2 : Création de deux instances de type SeanceTP portant sur la même
matière "POO"
SeanceTP* seanceA = new SeanceTP("POO", "G1", prof1);
SeanceTP* seanceB = new SeanceTP("POO", "G2", prof2);
// Étape 3 : Comparaison des deux séances
if (*seanceA == *seanceB)
cout << "Les deux séances concernent la même matière.\n";
else
cout << "Les deux séances sont différentes.\n";
cout << "Nombre total de séances : " << SeanceTP::getNbSeances() << "\n";
// Étape 4 : Création d’un tableau dynamique de 9 salles
SalleTP* salles = new SalleTP[9]{
SalleTP(1), SalleTP(2), SalleTP(3), SalleTP(4), SalleTP(5),
SalleTP(6), SalleTP(7), SalleTP(8), SalleTP(9)
};
// Étape 5 : Création des enseignants pour les séances de la salle 1
Enseignant* enseignant1 = new Enseignant("Oujdi", "Ali", "Informatique");
Enseignant* enseignant2 = new Enseignant("Berkani", "Lina", "Mathématiques");
// Étape 6 : Création de 4 séances pour la salle 1
SeanceTP* seance1 = new SeanceTP("POO", "SMI-S5-A", enseignant1);
SeanceTP* seance2 = new SeanceTP("POO", "SMI-S5-B", new Enseignant("Oujdi",
"Ali", "Informatique"));
SeanceTP* seance3 = new SeanceTP("C++", "SMA-S5-C", enseignant2);
SeanceTP* seance4 = new SeanceTP("C++", "SMA-S5-D", new Enseignant("Berkani",
"Lina", "Mathématiques"));
// Étape 7 : Affectation des séances
salles[0].affecterSeance(0, 0, seance1);
salles[0].affecterSeance(0, 1, seance2);
salles[0].affecterSeance(3, 2, seance3);
salles[0].affecterSeance(3, 3, seance4);
// Étape 8 : Affichages
cout << "\n--- Emploi du temps de la salle 1 ---\n";
salles[0].affichEmploiTemps();
cout << "\nNombre total de séances créées : " << SeanceTP::getNbSeances() << "\
n";
SalleTP::afficherCapacite();
// Étape 9 : Libération mémoire
delete[] salles;
delete seanceA;
delete seanceB;
delete seance1;
delete seance2;
delete seance3;
delete seance4;
delete prof1;
delete prof2;
delete enseignant1;
delete enseignant2;
return 0;
}