This repository was archived by the owner on Aug 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSemestre.cpp
More file actions
46 lines (41 loc) · 1.35 KB
/
Semestre.cpp
File metadata and controls
46 lines (41 loc) · 1.35 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
#include "Semestre.h"
#include "Etudiant.h"
Semestre::Semestre(Saison s, unsigned int a):saison(s)
{
if (a<1972||a>2099)
{
throw SemestreException("annee "+std::to_string(a)+" non valide");
}
TemplateManager<Semestre>& tSemestre=TemplateManager<Semestre>::getInstance();
QString test = ""+s.getNom()+QString::number(a);
if(!tSemestre.alreadyExist(test))
{
code=test;
annee=a;
tSemestre.New(*this);
}
else
{
throw SaisonException("Erreur : le semestre "+test.toStdString()+" existe deja !");
}
}
void Semestre::destroy()
{
TemplateManager<Etudiant>& tEtudiant=TemplateManager<Etudiant>::getInstance();
if(tEtudiant.size()>0)//pour chaque étudiant, on enlève les isncriptions
{
for(std::vector<Etudiant>::iterator it = tEtudiant.getIterator();it!=tEtudiant.end();it++)//on supprime toutes les inscriptions ayant ce semestre
{
Dossier dos=it->getDossier();
std::vector<Inscription> inscr = dos.getInscription();
for(std::vector<Inscription>::iterator it2= inscr.begin();it2 != inscr.end();it2++)
{
if(it2->getSemestre()==*this)
{
dos.deleteInscription(*it2);
it->setDossier(dos);
}
}
}
}
}