This repository has been archived by the owner on Aug 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
InscriptionPassee.cpp
164 lines (144 loc) · 5.4 KB
/
InscriptionPassee.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
#include "includes.h"
void InscriptionPassee::setResultat(unsigned int i, Note res){
if(existUV(i))
Resultat[i]=res;
else
cout<<"Erreur : L'UV demandée n'existe pas (index out of range)\n";
}
/* Retourne le nombre de Crédits de la Catégorie obtenus lors de ce semestre
* Argument : (optionnel) code du Cursus - la fonction retourne alors le nombre de crédits CS obtenus spécifiques à ce Cursus
*/
unsigned int InscriptionPassee::getNbCreditsCat(Categorie cat, QString cursus /*=QString::null*/) const {
unsigned int res=0;
UVManager* UVManage = UVManager::getInstance();
if(cursus!=""){
for (unsigned int i=0; i<getTailleTab(); i++)
if(isValidee(i)&&UVManage->hasCursus(getListUV()[i],cursus))
res+=UVManage->getNbCreditsCategorie(getListUV()[i], cat);
}
else {
for (unsigned int i=0; i<getTailleTab(); i++)
if(isValidee(i))
res+=UVManage->getNbCreditsCategorie(getListUV()[i], cat);
}
return res;
}
/* Retourne le nombre de Crédits CS obtenus lors de ce semestre
* Argument : (optionnel) code du Cursus - la fonction retourne alors le nombre de crédits CS obtenus spécifiques à ce Cursus
*/
unsigned int InscriptionPassee::getNbCreditsCS(QString cursus /*=QString::null*/) const {
unsigned int res=0;
UVManager* UVManage = UVManager::getInstance();
if(cursus!=""){
cout<<"Cursus non vide\n";
for (unsigned int i=0; i<getTailleTab(); i++){
cout<<"Parcours la liste des UVs\n";
if(isValidee(i)&&UVManage->hasCursus(getListUV()[i],cursus)){
cout<<"UV validee et cursus correspondant\n";
res+=UVManage->getNbCreditsCategorie(getListUV()[i], CS);
}
}
}
else {
for (unsigned int i=0; i<getTailleTab(); i++)
if(isValidee(i))
res+=UVManage->getNbCreditsCategorie(getListUV()[i], CS);
}
return res;
}
unsigned int InscriptionPassee::getNbCreditsTM(QString cursus /*=QString::null*/) const {
unsigned int res=0;
UVManager* UVManage = UVManager::getInstance();
if(cursus!=""){
for (unsigned int i=0; i<getTailleTab(); i++)
if(isValidee(i)&&UVManage->hasCursus(getListUV()[i],cursus))
res+=UVManage->getNbCreditsCategorie(getListUV()[i], TM);
}
else
for (unsigned int i=0; i<getTailleTab(); i++)
if(isValidee(i))
res+=UVManage->getNbCreditsCategorie(getListUV()[i], TM);
return res;
}
unsigned int InscriptionPassee::getNbCreditsTSH(QString cursus /*=QString::null*/) const {
unsigned int res=0;
UVManager* UVManage = UVManager::getInstance();
if(cursus!=""){
for (unsigned int i=0; i<getTailleTab(); i++)
if(isValidee(i)&&UVManage->hasCursus(getListUV()[i],cursus))
res+=UVManage->getNbCreditsCategorie(getListUV()[i], TSH);
}
else
for (unsigned int i=0; i<getTailleTab(); i++)
if(isValidee(i))
res+=UVManage->getNbCreditsCategorie(getListUV()[i], TSH);
return res;
}
unsigned int InscriptionPassee::getNbCreditsSP(QString cursus /*=QString::null*/) const {
unsigned int res=0;
UVManager* UVManage = UVManager::getInstance();
if(cursus!=""){
for (unsigned int i=0; i<getTailleTab(); i++)
if(isValidee(i)&&UVManage->hasCursus(getListUV()[i],cursus))
res+=UVManage->getNbCreditsCategorie(getListUV()[i], SP);
}
else
for (unsigned int i=0; i<getTailleTab(); i++)
if(isValidee(i))
res+=UVManage->getNbCreditsCategorie(getListUV()[i], SP);
return res;
}
unsigned int InscriptionPassee::getNbCreditsTot(QString cursus /*=""*/) const {
unsigned int res=0;
UVManager* UVManage = UVManager::getInstance();
if(cursus!=""){
for (unsigned int i=0; i<getTailleTab(); i++)
if(isValidee(i)&&UVManage->hasCursus(getListUV()[i],cursus))
res+=UVManage->getNbTotCredits(getListUV()[i]);
}
else
for (unsigned int i=0; i<getTailleTab(); i++)
if(isValidee(i))
res+=UVManage->getNbTotCredits(getListUV()[i]);
return res;
}
//Retourne true si l'UV est validée, false sinon
bool InscriptionPassee::isValidee(unsigned int i) const{
if(existUV(i)){
if(Resultat[i]!=FX&&Resultat[i]!=F&&Resultat[i]!=RES&&Resultat[i]!=ABS)
return true;
}
cout<<"UV non validee\n";
return false;
}
void InscriptionPassee::addUV(QString uv){
cout<<"Erreur : Il faut une note avec l UV. Utiliser 'addUVwithNote()'\n";
}
void InscriptionPassee::addUVwithNote(QString uv, Note res){
if(TabUVs.contains(uv))
cout<<"Erreur:UV deja dans le tableau";
else
{
TabUVs.append(uv);
if (tailleTab==0){
//Cas de la première UV
//Création d'un tableau de une case et ajout d'une QString
Resultat=new Note[1];
Resultat[0]=res;
//Incrémentation de la taille du tableau
tailleTab++;
}
else
{
Note* newRes= new Note[tailleTab+1];
for(unsigned int i=0; i<tailleTab; i++){
newRes[i]=Resultat[i];
}
Note* oldRes=Resultat;
Resultat=newRes;
Resultat[tailleTab]=res;
tailleTab++;
delete[] oldRes;
}
}
}