commit
This commit is contained in:
parent
a70b104817
commit
36319a7b7f
8 changed files with 207 additions and 153 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
main.exe
|
|
||||||
singleFile.exe
|
|
10
conf.c
10
conf.c
|
@ -91,6 +91,7 @@ ptListener newListenerChain() {
|
||||||
listenerChain -> prev = NULL;
|
listenerChain -> prev = NULL;
|
||||||
listenerChain -> next = (ptListener) malloc(sizeof(tListener));
|
listenerChain -> next = (ptListener) malloc(sizeof(tListener));
|
||||||
listenerChain -> next -> prev = listenerChain;
|
listenerChain -> next -> prev = listenerChain;
|
||||||
|
listenerChain -> next -> next = NULL;
|
||||||
listenerChain -> id = -1;
|
listenerChain -> id = -1;
|
||||||
|
|
||||||
return listenerChain;
|
return listenerChain;
|
||||||
|
@ -159,20 +160,15 @@ void addConfToConfList(ptConfList confList, ptConf conf, int grade) {
|
||||||
void removeConfFromConfList(ptConfList confList, ptConf conf) {
|
void removeConfFromConfList(ptConfList confList, ptConf conf) {
|
||||||
ptConfList px = confList;
|
ptConfList px = confList;
|
||||||
|
|
||||||
while (px -> next != NULL && px -> conf != conf) {
|
while (px -> next != NULL && px -> next -> conf != conf) {
|
||||||
px = px -> next;
|
px = px -> next;
|
||||||
}
|
}
|
||||||
|
|
||||||
printConfList(confList -> next);
|
|
||||||
printf("%d\n", px -> conf -> id);
|
|
||||||
|
|
||||||
if (px -> next != NULL && px -> next -> conf == conf) {
|
if (px -> next != NULL && px -> next -> conf == conf) {
|
||||||
ptConfList tmp = px -> next -> next;
|
ptConfList tmp = px -> next -> next;
|
||||||
free(px -> next);
|
free(px -> next);
|
||||||
px -> next = tmp;
|
px -> next = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
system("pause");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void printConfList(ptConfList confList) {
|
void printConfList(ptConfList confList) {
|
||||||
|
@ -202,7 +198,7 @@ void addListenerToListenerList(ptListenerList listenerList, ptListener listener,
|
||||||
void removeListenerFromListenerList(ptListenerList listenerList, ptListener listener) {
|
void removeListenerFromListenerList(ptListenerList listenerList, ptListener listener) {
|
||||||
ptListenerList px = listenerList;
|
ptListenerList px = listenerList;
|
||||||
|
|
||||||
while (px -> next != NULL && px -> listener != listener) {
|
while (px -> next != NULL && px -> next -> listener != listener) {
|
||||||
px = px -> next;
|
px = px -> next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
1,Rapport_du_GIEC,Jean_Jouzzel,15,11,2022
|
||||||
2,L_esprit_critique,Thomas_Durand,6,2,2023
|
2,L_esprit_critique,Thomas_Durand,6,2,2023
|
||||||
3,La_resilience,Arthur_Keller,20,10,2022
|
3,La_resilience,Arthur_Keller,20,10,2022
|
||||||
4,American_lobbying,Salah_Oueslati,30,11,2023
|
4,American_lobbying,Salah_Oueslati,30,11,2023
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
1:12;0,1;4
|
1:12;0,1;4
|
||||||
|
2:12;0,1;4
|
||||||
|
3:12;0,1;4
|
||||||
|
4:12;0,1;4
|
||||||
9:20;5
|
9:20;5
|
||||||
|
|
|
@ -94,8 +94,10 @@ void saveRelations(ptConf confChain) {
|
||||||
FILE *file = fopen("./data/relations", "w");
|
FILE *file = fopen("./data/relations", "w");
|
||||||
ptConf px = confChain;
|
ptConf px = confChain;
|
||||||
ptListenerList py;
|
ptListenerList py;
|
||||||
|
printf("test");
|
||||||
while(px -> next != NULL){
|
while(px -> next != NULL){
|
||||||
py = px -> listeners;
|
printf("test");
|
||||||
|
py = px -> listeners -> next;
|
||||||
|
|
||||||
if (py -> next != NULL) {
|
if (py -> next != NULL) {
|
||||||
fprintf(file, "%d:", px -> id);
|
fprintf(file, "%d:", px -> id);
|
||||||
|
|
BIN
main.exe
Normal file
BIN
main.exe
Normal file
Binary file not shown.
|
@ -105,6 +105,8 @@ void menuConf(ptConf confChain, ptListener listenerChain) {
|
||||||
system("cls");
|
system("cls");
|
||||||
drawMenu(options, 5);
|
drawMenu(options, 5);
|
||||||
goToCoords(0, 13);
|
goToCoords(0, 13);
|
||||||
|
tasse();
|
||||||
|
printf("\n");
|
||||||
printf("Que voulez-vous faire ? : ");
|
printf("Que voulez-vous faire ? : ");
|
||||||
int choice;
|
int choice;
|
||||||
scanf("%d", &choice);
|
scanf("%d", &choice);
|
||||||
|
@ -160,6 +162,15 @@ void menuConf(ptConf confChain, ptListener listenerChain) {
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
|
ptConf px = confChain -> next;
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
while (px -> next != NULL) {
|
||||||
|
printf("%d : %s\n", px -> id, px -> title);
|
||||||
|
px = px -> next;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
printf("Id de la conference a supprimer : ");
|
printf("Id de la conference a supprimer : ");
|
||||||
|
@ -167,6 +178,7 @@ void menuConf(ptConf confChain, ptListener listenerChain) {
|
||||||
|
|
||||||
removeConf(confChain, id);
|
removeConf(confChain, id);
|
||||||
saveConf(confChain -> next);
|
saveConf(confChain -> next);
|
||||||
|
saveRelations(confChain -> next);
|
||||||
menuConf(confChain, listenerChain);
|
menuConf(confChain, listenerChain);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -216,6 +228,8 @@ void menuAbo(ptConf confChain, ptListener listenerChain) {
|
||||||
system("cls");
|
system("cls");
|
||||||
drawMenu(options, 4);
|
drawMenu(options, 4);
|
||||||
goToCoords(0, 12);
|
goToCoords(0, 12);
|
||||||
|
tasse();
|
||||||
|
printf("\n");
|
||||||
printf("Que voulez-vous faire ? : ");
|
printf("Que voulez-vous faire ? : ");
|
||||||
int choice;
|
int choice;
|
||||||
scanf("%d", &choice);
|
scanf("%d", &choice);
|
||||||
|
@ -264,6 +278,15 @@ void menuAbo(ptConf confChain, ptListener listenerChain) {
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
|
ptListener px = listenerChain -> next;
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
while (px -> next != NULL) {
|
||||||
|
printf("%d : %s\n", px -> id, px -> name);
|
||||||
|
px = px -> next;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
printf("Id de l'abonne a supprimer : ");
|
printf("Id de l'abonne a supprimer : ");
|
||||||
|
@ -271,6 +294,7 @@ void menuAbo(ptConf confChain, ptListener listenerChain) {
|
||||||
|
|
||||||
removeListener(listenerChain, id);
|
removeListener(listenerChain, id);
|
||||||
saveListeners(listenerChain -> next);
|
saveListeners(listenerChain -> next);
|
||||||
|
saveRelations(confChain -> next);
|
||||||
menuAbo(confChain, listenerChain);
|
menuAbo(confChain, listenerChain);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -308,6 +332,21 @@ void menu(ptConf confChain, ptListener listenerChain)
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
|
ptConf px = confChain -> next;
|
||||||
|
ptListener py = listenerChain -> next;
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
while (px -> next != NULL) {
|
||||||
|
printf("%d : %s\n", px -> id, px -> title);
|
||||||
|
px = px -> next;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
while (py -> next != NULL) {
|
||||||
|
printf("%d : %s\n", py -> id, py -> name);
|
||||||
|
py = py -> next;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
int confId, listenerId, grade;
|
int confId, listenerId, grade;
|
||||||
printf("Entrez l'ID de la conference : ");
|
printf("Entrez l'ID de la conference : ");
|
||||||
scanf("%d", &confId);
|
scanf("%d", &confId);
|
||||||
|
@ -317,7 +356,7 @@ void menu(ptConf confChain, ptListener listenerChain)
|
||||||
scanf("%d", &grade);
|
scanf("%d", &grade);
|
||||||
|
|
||||||
if (participateToConf(confChain, listenerChain, confId, listenerId, grade) != -1) {
|
if (participateToConf(confChain, listenerChain, confId, listenerId, grade) != -1) {
|
||||||
saveRelations(confChain);
|
saveRelations(confChain -> next);
|
||||||
} else {
|
} else {
|
||||||
printf("La note doit etre comprise entre 0 et 5 et l'abonne ne doit pas avoir deja participe a la conference\n\n");
|
printf("La note doit etre comprise entre 0 et 5 et l'abonne ne doit pas avoir deja participe a la conference\n\n");
|
||||||
system("pause");
|
system("pause");
|
||||||
|
|
275
singleFile.c
275
singleFile.c
|
@ -60,8 +60,10 @@ ptListener newListenerChain();
|
||||||
int addListener(ptListener listenerChain, int id, char name[], int age, int level);
|
int addListener(ptListener listenerChain, int id, char name[], int age, int level);
|
||||||
void removeListener(ptListener listenerChain, int id);
|
void removeListener(ptListener listenerChain, int id);
|
||||||
void addConfToConfList(ptConfList confList, ptConf conf, int grade);
|
void addConfToConfList(ptConfList confList, ptConf conf, int grade);
|
||||||
|
void removeConfFromConfList(ptConfList confList, ptConf conf);
|
||||||
void printConfList(ptConfList confList);
|
void printConfList(ptConfList confList);
|
||||||
void addListenerToListenerList(ptListenerList listenerList, ptListener listener, int grade);
|
void addListenerToListenerList(ptListenerList listenerList, ptListener listener, int grade);
|
||||||
|
void removeListenerFromListenerList(ptListenerList listenerList, ptListener listener);
|
||||||
void printListenerList(ptListenerList listenerList);
|
void printListenerList(ptListenerList listenerList);
|
||||||
int participateToConf(ptConf confChain, ptListener listenerChain, int confId, int listenerId, int grade);
|
int participateToConf(ptConf confChain, ptListener listenerChain, int confId, int listenerId, int grade);
|
||||||
int confGradeAvg(ptConf conf);
|
int confGradeAvg(ptConf conf);
|
||||||
|
@ -89,7 +91,9 @@ ptConf newConfChain()
|
||||||
{
|
{
|
||||||
ptConf confChain = (ptConf)malloc(sizeof(tConf));
|
ptConf confChain = (ptConf)malloc(sizeof(tConf));
|
||||||
|
|
||||||
confChain->next = NULL;
|
confChain->next = (ptConf)malloc(sizeof(tConf));
|
||||||
|
confChain->next->next = NULL;
|
||||||
|
confChain->id = -1;
|
||||||
|
|
||||||
return confChain;
|
return confChain;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +114,9 @@ void addConf(ptConf confChain, int id, char title[], char speaker[], int day, in
|
||||||
strcpy(px->title, title);
|
strcpy(px->title, title);
|
||||||
strcpy(px->speaker, speaker);
|
strcpy(px->speaker, speaker);
|
||||||
px->listeners = (ptListenerList)malloc(sizeof(tListenerList));
|
px->listeners = (ptListenerList)malloc(sizeof(tListenerList));
|
||||||
px->listeners->next = NULL;
|
px->listeners->next = (ptListenerList)malloc(sizeof(tListenerList));
|
||||||
|
px->listeners->listener = NULL;
|
||||||
|
px->listeners->next->next = NULL;
|
||||||
px->next = (ptConf)malloc(sizeof(tConf));
|
px->next = (ptConf)malloc(sizeof(tConf));
|
||||||
px->next->next = NULL;
|
px->next->next = NULL;
|
||||||
}
|
}
|
||||||
|
@ -119,42 +125,24 @@ void removeConf(ptConf confChain, int id)
|
||||||
{
|
{
|
||||||
ptConf px = confChain;
|
ptConf px = confChain;
|
||||||
|
|
||||||
if (px->next == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (px->next->next == NULL)
|
|
||||||
{
|
|
||||||
|
|
||||||
free(px->next);
|
|
||||||
px->next = NULL;
|
|
||||||
}
|
|
||||||
else if (px->id == id && px->next->next != NULL)
|
|
||||||
{
|
|
||||||
px->id = px->next->id;
|
|
||||||
strcpy(px->title, px->next->title);
|
|
||||||
strcpy(px->speaker, px->next->speaker);
|
|
||||||
px->day = px->next->day;
|
|
||||||
px->month = px->next->month;
|
|
||||||
px->year = px->next->year;
|
|
||||||
|
|
||||||
ptConf tmp = px->next;
|
|
||||||
px->next = px->next->next;
|
|
||||||
free(tmp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while (px->next != NULL && px->next->id != id)
|
while (px->next != NULL && px->next->id != id)
|
||||||
{
|
{
|
||||||
px = px->next;
|
px = px->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (px->next->id == id)
|
if (px->next != NULL && px->next->id == id)
|
||||||
{
|
{
|
||||||
ptConf tmp = px->next;
|
ptListenerList py = px->next->listeners->next;
|
||||||
px->next = px->next->next;
|
|
||||||
free(tmp);
|
while (py->next != NULL)
|
||||||
|
{
|
||||||
|
removeConfFromConfList(py->listener->confs, px->next);
|
||||||
|
py = py->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ptConf tmp = px->next->next;
|
||||||
|
free(px->next);
|
||||||
|
px->next = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +169,10 @@ ptListener newListenerChain()
|
||||||
ptListener listenerChain = (ptListener)malloc(sizeof(tListener));
|
ptListener listenerChain = (ptListener)malloc(sizeof(tListener));
|
||||||
|
|
||||||
listenerChain->prev = NULL;
|
listenerChain->prev = NULL;
|
||||||
listenerChain->next = NULL;
|
listenerChain->next = (ptListener)malloc(sizeof(tListener));
|
||||||
|
listenerChain->next->prev = listenerChain;
|
||||||
|
listenerChain->next->next = NULL;
|
||||||
|
listenerChain->id = -1;
|
||||||
|
|
||||||
return listenerChain;
|
return listenerChain;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +196,9 @@ int addListener(ptListener listenerChain, int id, char name[], int age, int leve
|
||||||
px->age = age;
|
px->age = age;
|
||||||
px->level = level;
|
px->level = level;
|
||||||
px->confs = (ptConfList)malloc(sizeof(tConfList));
|
px->confs = (ptConfList)malloc(sizeof(tConfList));
|
||||||
px->confs->next = NULL;
|
px->confs->next = (ptConfList)malloc(sizeof(tConfList));
|
||||||
|
px->confs->conf = NULL;
|
||||||
|
px->confs->next->next = NULL;
|
||||||
px->next = (ptListener)malloc(sizeof(tListener));
|
px->next = (ptListener)malloc(sizeof(tListener));
|
||||||
px->next->next = NULL;
|
px->next->next = NULL;
|
||||||
px->next->prev = px;
|
px->next->prev = px;
|
||||||
|
@ -215,41 +208,26 @@ int addListener(ptListener listenerChain, int id, char name[], int age, int leve
|
||||||
void removeListener(ptListener listenerChain, int id)
|
void removeListener(ptListener listenerChain, int id)
|
||||||
{
|
{
|
||||||
ptListener px = listenerChain;
|
ptListener px = listenerChain;
|
||||||
if (px->next == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (px->id == id && px->next->next == NULL)
|
|
||||||
{
|
|
||||||
free(px->next);
|
|
||||||
px->next = NULL;
|
|
||||||
}
|
|
||||||
else if (px->id == id)
|
|
||||||
{
|
|
||||||
px->id = px->next->id;
|
|
||||||
strcpy(px->name, px->next->name);
|
|
||||||
px->age = px->next->age;
|
|
||||||
px->level = px->next->level;
|
|
||||||
|
|
||||||
ptListener tmp = px->next;
|
|
||||||
px->next = px->next->next;
|
|
||||||
px->next->prev = px;
|
|
||||||
free(tmp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while (px->next != NULL && px->next->id != id)
|
while (px->next != NULL && px->next->id != id)
|
||||||
{
|
{
|
||||||
px = px->next;
|
px = px->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (px->next->id == id)
|
if (px->next != NULL && px->next->id == id)
|
||||||
{
|
{
|
||||||
ptListener tmp = px->next;
|
ptConfList py = px->next->confs->next;
|
||||||
px->next = px->next->next;
|
|
||||||
px->next->prev = px;
|
while (py->next != NULL)
|
||||||
free(tmp);
|
{
|
||||||
|
removeListenerFromListenerList(py->conf->listeners, px->next);
|
||||||
|
py = py->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ptListener tmp = px->next->next;
|
||||||
|
free(px->next);
|
||||||
|
px->next = tmp;
|
||||||
|
px->next->prev = px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,52 +246,28 @@ void addConfToConfList(ptConfList confList, ptConf conf, int grade)
|
||||||
px->next->next = NULL;
|
px->next->next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeConfFromConfList(ptConf confChain, ptConfList confList, ptConf conf)
|
void removeConfFromConfList(ptConfList confList, ptConf conf)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (confList->next == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (confList->next->next == NULL && confList->conf == conf)
|
|
||||||
{
|
|
||||||
free(confList->next);
|
|
||||||
confList->next = NULL;
|
|
||||||
}
|
|
||||||
else if (confList->conf == conf && confList->next->next != NULL)
|
|
||||||
{
|
|
||||||
confList->conf = confList->next->conf;
|
|
||||||
confList->grade = confList->next->grade;
|
|
||||||
ptConfList tmp = confList->next->next;
|
|
||||||
free(confList->next);
|
|
||||||
confList->next = tmp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ptConfList px = confList;
|
ptConfList px = confList;
|
||||||
|
|
||||||
while (px->next != NULL && px->next->conf != conf)
|
while (px->next != NULL && px->next->conf != conf)
|
||||||
{
|
{
|
||||||
if (confChain == conf && px->conf == conf->next) {
|
|
||||||
px->conf
|
|
||||||
}
|
|
||||||
|
|
||||||
px = px->next;
|
px = px->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (px->next->conf == conf) {
|
if (px->next != NULL && px->next->conf == conf)
|
||||||
|
{
|
||||||
ptConfList tmp = px->next->next;
|
ptConfList tmp = px->next->next;
|
||||||
free(px->next);
|
free(px->next);
|
||||||
px->next = tmp;
|
px->next = tmp;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void printConfList(ptConfList confList)
|
void printConfList(ptConfList confList)
|
||||||
{
|
{
|
||||||
ptConfList px = confList;
|
ptConfList px = confList;
|
||||||
|
|
||||||
printf(" Participation aux conferences : ");
|
printf("Participation aux conferences : ");
|
||||||
while (px->next != NULL)
|
while (px->next != NULL)
|
||||||
{
|
{
|
||||||
printf("%s(%d) ", px->conf->title, px->grade);
|
printf("%s(%d) ", px->conf->title, px->grade);
|
||||||
|
@ -337,11 +291,28 @@ void addListenerToListenerList(ptListenerList listenerList, ptListener listener,
|
||||||
px->next->next = NULL;
|
px->next->next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeListenerFromListenerList(ptListenerList listenerList, ptListener listener)
|
||||||
|
{
|
||||||
|
ptListenerList px = listenerList;
|
||||||
|
|
||||||
|
while (px->next != NULL && px->next->listener != listener)
|
||||||
|
{
|
||||||
|
px = px->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (px->next != NULL && px->next->listener == listener)
|
||||||
|
{
|
||||||
|
ptListenerList tmp = px->next->next;
|
||||||
|
free(px->next);
|
||||||
|
px->next = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void printListenerList(ptListenerList listenerList)
|
void printListenerList(ptListenerList listenerList)
|
||||||
{
|
{
|
||||||
ptListenerList px = listenerList;
|
ptListenerList px = listenerList;
|
||||||
|
|
||||||
printf(" Participants : ");
|
printf("Participants : ");
|
||||||
while (px->next != NULL)
|
while (px->next != NULL)
|
||||||
{
|
{
|
||||||
printf("%s(%d) ", px->listener->name, px->grade);
|
printf("%s(%d) ", px->listener->name, px->grade);
|
||||||
|
@ -366,7 +337,7 @@ int participateToConf(ptConf confChain, ptListener listenerChain, int confId, in
|
||||||
px = px->next;
|
px = px->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
pz = px->listeners;
|
pz = px->listeners->next;
|
||||||
while (pz->next != NULL)
|
while (pz->next != NULL)
|
||||||
{
|
{
|
||||||
if (pz->listener->id == listenerId)
|
if (pz->listener->id == listenerId)
|
||||||
|
@ -394,7 +365,7 @@ int participateToConf(ptConf confChain, ptListener listenerChain, int confId, in
|
||||||
|
|
||||||
int confGradeAvg(ptConf conf)
|
int confGradeAvg(ptConf conf)
|
||||||
{
|
{
|
||||||
ptListenerList px = conf->listeners;
|
ptListenerList px = conf->listeners->next;
|
||||||
int total = 0, nb = 0;
|
int total = 0, nb = 0;
|
||||||
|
|
||||||
while (px->next != NULL)
|
while (px->next != NULL)
|
||||||
|
@ -416,7 +387,7 @@ int confGradeAvg(ptConf conf)
|
||||||
|
|
||||||
int confParticipations(ptConf conf)
|
int confParticipations(ptConf conf)
|
||||||
{
|
{
|
||||||
ptListenerList px = conf->listeners;
|
ptListenerList px = conf->listeners->next;
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
|
|
||||||
while (px->next != NULL)
|
while (px->next != NULL)
|
||||||
|
@ -545,9 +516,11 @@ void saveRelations(ptConf confChain)
|
||||||
FILE *file = fopen("./data/relations", "w");
|
FILE *file = fopen("./data/relations", "w");
|
||||||
ptConf px = confChain;
|
ptConf px = confChain;
|
||||||
ptListenerList py;
|
ptListenerList py;
|
||||||
|
printf("test");
|
||||||
while (px->next != NULL)
|
while (px->next != NULL)
|
||||||
{
|
{
|
||||||
py = px->listeners;
|
printf("test");
|
||||||
|
py = px->listeners->next;
|
||||||
|
|
||||||
if (py->next != NULL)
|
if (py->next != NULL)
|
||||||
{
|
{
|
||||||
|
@ -585,7 +558,6 @@ void drawMenu(char *options[], int lenght);
|
||||||
void tasse();
|
void tasse();
|
||||||
void menuConf(ptConf confChain, ptListener listenerChain);
|
void menuConf(ptConf confChain, ptListener listenerChain);
|
||||||
void menuAbo(ptConf confChain, ptListener listenerChain);
|
void menuAbo(ptConf confChain, ptListener listenerChain);
|
||||||
|
|
||||||
void menu(ptConf confChain, ptListener listenerChain);
|
void menu(ptConf confChain, ptListener listenerChain);
|
||||||
|
|
||||||
void goToCoords(int x, int y)
|
void goToCoords(int x, int y)
|
||||||
|
@ -694,6 +666,8 @@ void menuConf(ptConf confChain, ptListener listenerChain)
|
||||||
system("cls");
|
system("cls");
|
||||||
drawMenu(options, 5);
|
drawMenu(options, 5);
|
||||||
goToCoords(0, 13);
|
goToCoords(0, 13);
|
||||||
|
tasse();
|
||||||
|
printf("\n");
|
||||||
printf("Que voulez-vous faire ? : ");
|
printf("Que voulez-vous faire ? : ");
|
||||||
int choice;
|
int choice;
|
||||||
scanf("%d", &choice);
|
scanf("%d", &choice);
|
||||||
|
@ -702,21 +676,21 @@ void menuConf(ptConf confChain, ptListener listenerChain)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
ptConf px = confChain;
|
ptConf px = confChain->next;
|
||||||
|
|
||||||
while (px->next != NULL)
|
while (px->next != NULL)
|
||||||
{
|
{
|
||||||
printf(" Id : %d\n Titre : %s\n Conferencier : %s\n", px->id, px->title, px->speaker);
|
printf("Id : %d\nTitre : %s\nConferencier : %s\n", px->id, px->title, px->speaker);
|
||||||
printf(" Date : %d/%d/%d\n", px->day, px->month, px->year);
|
printf("Date : %d/%d/%d\n", px->day, px->month, px->year);
|
||||||
printf(" Nombre de participants : %d\n", confParticipations(px));
|
printf("Nombre de participants : %d\n", confParticipations(px));
|
||||||
if (px->listeners->next != NULL)
|
if (px->listeners->next != NULL)
|
||||||
{
|
{
|
||||||
printListenerList(px->listeners);
|
printListenerList(px->listeners->next);
|
||||||
}
|
}
|
||||||
int avg;
|
int avg;
|
||||||
if ((avg = confGradeAvg(px) != -1))
|
if ((avg = confGradeAvg(px) != -1))
|
||||||
{
|
{
|
||||||
printf(" Moyenne des notes : %d\n", confGradeAvg(px));
|
printf("Moyenne des notes : %d\n", confGradeAvg(px));
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
px = px->next;
|
px = px->next;
|
||||||
|
@ -733,32 +707,43 @@ void menuConf(ptConf confChain, ptListener listenerChain)
|
||||||
char speaker[20];
|
char speaker[20];
|
||||||
|
|
||||||
id = findConfId(confChain);
|
id = findConfId(confChain);
|
||||||
printf(" Titre de la conference : ");
|
printf("Titre de la conference : ");
|
||||||
scanf("%29s", &title);
|
scanf("%29s", &title);
|
||||||
printf(" Nom du conferencier : ");
|
printf("Nom du conferencier : ");
|
||||||
scanf("%19s", &speaker);
|
scanf("%19s", &speaker);
|
||||||
printf(" Jour : ");
|
printf("Jour : ");
|
||||||
scanf("%d", &day);
|
scanf("%d", &day);
|
||||||
printf(" Mois : ");
|
printf("Mois : ");
|
||||||
scanf("%d", &month);
|
scanf("%d", &month);
|
||||||
printf(" Annee : ");
|
printf("Annee : ");
|
||||||
scanf("%d", &year);
|
scanf("%d", &year);
|
||||||
|
|
||||||
addConf(confChain, id, title, speaker, day, month, year);
|
addConf(confChain, id, title, speaker, day, month, year);
|
||||||
saveConf(confChain);
|
saveConf(confChain->next);
|
||||||
menuConf(confChain, listenerChain);
|
menuConf(confChain, listenerChain);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
|
ptConf px = confChain->next;
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
while (px->next != NULL)
|
||||||
|
{
|
||||||
|
printf("%d : %s\n", px->id, px->title);
|
||||||
|
px = px->next;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
printf(" Id de la conference a supprimer : ");
|
printf("Id de la conference a supprimer : ");
|
||||||
scanf("%d", &id);
|
scanf("%d", &id);
|
||||||
|
|
||||||
removeConf(confChain, id);
|
removeConf(confChain, id);
|
||||||
saveConf(confChain);
|
saveConf(confChain->next);
|
||||||
|
saveRelations(confChain->next);
|
||||||
menuConf(confChain, listenerChain);
|
menuConf(confChain, listenerChain);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -766,11 +751,11 @@ void menuConf(ptConf confChain, ptListener listenerChain)
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
int day, month, year, time;
|
int day, month, year, time;
|
||||||
printf(" Jour : ");
|
printf("Jour : ");
|
||||||
scanf("%d", &day);
|
scanf("%d", &day);
|
||||||
printf(" Mois : ");
|
printf("Mois : ");
|
||||||
scanf("%d", &month);
|
scanf("%d", &month);
|
||||||
printf(" Annee : ");
|
printf("Annee : ");
|
||||||
scanf("%d", &year);
|
scanf("%d", &year);
|
||||||
|
|
||||||
time = day + 31 * month + 365 * year;
|
time = day + 31 * month + 365 * year;
|
||||||
|
@ -795,7 +780,7 @@ void menuConf(ptConf confChain, ptListener listenerChain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveConf(confChain);
|
saveConf(confChain->next);
|
||||||
|
|
||||||
menuConf(confChain, listenerChain);
|
menuConf(confChain, listenerChain);
|
||||||
}
|
}
|
||||||
|
@ -815,7 +800,9 @@ void menuAbo(ptConf confChain, ptListener listenerChain)
|
||||||
system("cls");
|
system("cls");
|
||||||
drawMenu(options, 4);
|
drawMenu(options, 4);
|
||||||
goToCoords(0, 12);
|
goToCoords(0, 12);
|
||||||
printf(" Que voulez-vous faire ? : ");
|
tasse();
|
||||||
|
printf("\n");
|
||||||
|
printf("Que voulez-vous faire ? : ");
|
||||||
int choice;
|
int choice;
|
||||||
scanf("%d", &choice);
|
scanf("%d", &choice);
|
||||||
|
|
||||||
|
@ -823,14 +810,14 @@ void menuAbo(ptConf confChain, ptListener listenerChain)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
ptListener py = listenerChain;
|
ptListener py = listenerChain->next;
|
||||||
|
|
||||||
while (py->next != NULL)
|
while (py->next != NULL)
|
||||||
{
|
{
|
||||||
printf(" Id : %d\n Nom: %s\n Age: %d\n Niveau: %d\n", py->id, py->name, py->age, py->level);
|
printf("Id : %d\nNom: %s\nAge: %d\nNiveau: %d\n", py->id, py->name, py->age, py->level);
|
||||||
if (py->confs->next != NULL)
|
if (py->confs->next != NULL)
|
||||||
{
|
{
|
||||||
printConfList(py->confs);
|
printConfList(py->confs->next);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
py = py->next;
|
py = py->next;
|
||||||
|
@ -846,20 +833,20 @@ void menuAbo(ptConf confChain, ptListener listenerChain)
|
||||||
char name[20];
|
char name[20];
|
||||||
|
|
||||||
id = findListenerId(listenerChain);
|
id = findListenerId(listenerChain);
|
||||||
printf(" Nom : ");
|
printf("Nom : ");
|
||||||
scanf("%19s", &name);
|
scanf("%19s", &name);
|
||||||
printf(" Age : ");
|
printf("Age : ");
|
||||||
scanf("%d", &age);
|
scanf("%d", &age);
|
||||||
printf(" Niveau : ");
|
printf("Niveau : ");
|
||||||
scanf("%d", &level);
|
scanf("%d", &level);
|
||||||
|
|
||||||
if (addListener(listenerChain, id, name, age, level) != -1)
|
if (addListener(listenerChain, id, name, age, level) != -1)
|
||||||
{
|
{
|
||||||
saveListeners(listenerChain);
|
saveListeners(listenerChain->next);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf(" Le niveau de l'abonne doit etre compris entre 0 et 5.\n\n");
|
printf("Le niveau de l'abonne doit etre compris entre 0 et 5.\n\n");
|
||||||
system("pause");
|
system("pause");
|
||||||
}
|
}
|
||||||
menuAbo(confChain, listenerChain);
|
menuAbo(confChain, listenerChain);
|
||||||
|
@ -868,13 +855,24 @@ void menuAbo(ptConf confChain, ptListener listenerChain)
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
|
ptListener px = listenerChain->next;
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
while (px->next != NULL)
|
||||||
|
{
|
||||||
|
printf("%d : %s\n", px->id, px->name);
|
||||||
|
px = px->next;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
printf(" Id de l'abonne a supprimer : ");
|
printf("Id de l'abonne a supprimer : ");
|
||||||
scanf("%d", &id);
|
scanf("%d", &id);
|
||||||
|
|
||||||
removeListener(listenerChain, id);
|
removeListener(listenerChain, id);
|
||||||
saveListeners(listenerChain);
|
saveListeners(listenerChain->next);
|
||||||
|
saveRelations(confChain->next);
|
||||||
menuAbo(confChain, listenerChain);
|
menuAbo(confChain, listenerChain);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -896,7 +894,7 @@ void menu(ptConf confChain, ptListener listenerChain)
|
||||||
goToCoords(0, 13);
|
goToCoords(0, 13);
|
||||||
tasse();
|
tasse();
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf(" Que voulez-vous faire ? : ");
|
printf("Que voulez-vous faire ? : ");
|
||||||
int choice;
|
int choice;
|
||||||
scanf("%d", &choice);
|
scanf("%d", &choice);
|
||||||
|
|
||||||
|
@ -912,21 +910,38 @@ void menu(ptConf confChain, ptListener listenerChain)
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
|
ptConf px = confChain->next;
|
||||||
|
ptListener py = listenerChain->next;
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
while (px->next != NULL)
|
||||||
|
{
|
||||||
|
printf("%d : %s\n", px->id, px->title);
|
||||||
|
px = px->next;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
while (py->next != NULL)
|
||||||
|
{
|
||||||
|
printf("%d : %s\n", py->id, py->name);
|
||||||
|
py = py->next;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
int confId, listenerId, grade;
|
int confId, listenerId, grade;
|
||||||
printf(" Entrez l'ID de la conference : ");
|
printf("Entrez l'ID de la conference : ");
|
||||||
scanf("%d", &confId);
|
scanf("%d", &confId);
|
||||||
printf(" Entrez l'ID du participant : ");
|
printf("Entrez l'ID du participant : ");
|
||||||
scanf("%d", &listenerId);
|
scanf("%d", &listenerId);
|
||||||
printf(" Entrez la note attribuee par le participant : ");
|
printf("Entrez la note attribuee par le participant : ");
|
||||||
scanf("%d", &grade);
|
scanf("%d", &grade);
|
||||||
|
|
||||||
if (participateToConf(confChain, listenerChain, confId, listenerId, grade) != -1)
|
if (participateToConf(confChain, listenerChain, confId, listenerId, grade) != -1)
|
||||||
{
|
{
|
||||||
saveRelations(confChain);
|
saveRelations(confChain->next);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf(" La note doit etre comprise entre 0 et 5 et l'abonne ne doit pas avoir deja participe a la conference\n\n");
|
printf("La note doit etre comprise entre 0 et 5 et l'abonne ne doit pas avoir deja participe a la conference\n\n");
|
||||||
system("pause");
|
system("pause");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,7 +967,7 @@ void menu(ptConf confChain, ptListener listenerChain)
|
||||||
px = px->next;
|
px = px->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" La conférence la mieux notee est : %s\n\n", confMax->title);
|
printf("La conférence la mieux notee est : %s\n\n", confMax->title);
|
||||||
|
|
||||||
system("pause");
|
system("pause");
|
||||||
menu(confChain, listenerChain);
|
menu(confChain, listenerChain);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue