commit
This commit is contained in:
parent
6c8e100c6c
commit
555dcd39b7
6 changed files with 113 additions and 3 deletions
77
conf.c
77
conf.c
|
@ -40,6 +40,7 @@ void addConf(ptConf confChain, int id, char title[], char speaker[], int day, in
|
|||
strcpy(px -> title, title);
|
||||
strcpy(px -> speaker, speaker);
|
||||
px -> listeners = (ptListenerList) malloc(sizeof(tListenerList));
|
||||
px -> listeners -> next = NULL;
|
||||
px -> next = (ptConf) malloc(sizeof(tConf));
|
||||
px -> next -> next = NULL;
|
||||
}
|
||||
|
@ -110,6 +111,7 @@ void addListener(ptListener listenerChain, int id, char name[], int age, int lev
|
|||
px -> age = age;
|
||||
px -> level = level;
|
||||
px -> confs = (ptConfList) malloc(sizeof(tConfList));
|
||||
px -> confs -> next = NULL;
|
||||
px -> next = (ptListener) malloc(sizeof(tListener));
|
||||
px -> next -> next = NULL;
|
||||
px -> next -> prev = px;
|
||||
|
@ -144,3 +146,78 @@ void removeListener(ptListener listenerChain, int id) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addConfToConfList(ptConfList confList, ptConf conf) {
|
||||
ptConfList px = confList;
|
||||
|
||||
while (px -> next != NULL) {
|
||||
px = px -> next;
|
||||
}
|
||||
|
||||
px -> conf = conf;
|
||||
px -> next = (ptConfList) malloc(sizeof(tConfList));
|
||||
px -> next -> next = NULL;
|
||||
}
|
||||
|
||||
void printConfList(ptConfList confList) {
|
||||
ptConfList px = confList;
|
||||
|
||||
printf("Participation aux conferences : ");
|
||||
while (px -> next != NULL) {
|
||||
printf("%s ", px -> conf -> title);
|
||||
px = px -> next;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void addListenerToListenerList(ptListenerList listenerList, ptListener listener) {
|
||||
ptListenerList px = listenerList;
|
||||
|
||||
while (px -> next != NULL) {
|
||||
px = px -> next;
|
||||
}
|
||||
|
||||
px -> listener = listener;
|
||||
px -> next = (ptListenerList) malloc(sizeof(tListenerList));
|
||||
px -> next -> next = NULL;
|
||||
}
|
||||
|
||||
void printListenerList(ptListenerList listenerList) {
|
||||
ptListenerList px = listenerList;
|
||||
|
||||
printf("Participants : ");
|
||||
while (px -> next != NULL) {
|
||||
printf("%s ", px -> listener -> name);
|
||||
px = px -> next;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void participateToConf(ptConf confChain, ptListener listenerChain, int confId, int listenerId) {
|
||||
ptConf px = confChain;
|
||||
ptListener py = listenerChain;
|
||||
ptListenerList pz;
|
||||
|
||||
while (px -> next != NULL && px -> id != confId) {
|
||||
px = px -> next;
|
||||
}
|
||||
|
||||
pz = px -> listeners;
|
||||
while (pz -> next != NULL) {
|
||||
if (pz -> listener -> id == listenerId) {
|
||||
return;
|
||||
}
|
||||
pz = pz -> next;
|
||||
}
|
||||
|
||||
while (py -> next != NULL && py -> id != listenerId) {
|
||||
py = py -> next;
|
||||
}
|
||||
|
||||
if (px -> id != confId || py -> id != listenerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
addListenerToListenerList(px -> listeners, py);
|
||||
addConfToConfList(py -> confs, px);
|
||||
}
|
5
conf.h
5
conf.h
|
@ -47,5 +47,10 @@ int findListenerId(ptListener listenerChain);
|
|||
ptListener newListenerChain();
|
||||
void addListener(ptListener listenerChain, int id, char name[], int age, int level);
|
||||
void removeListener(ptListener listenerChain, int id);
|
||||
void addConfToConfList(ptConfList confList, ptConf conf);
|
||||
void printConfList(ptConfList confList);
|
||||
void addListenerToListenerList(ptListenerList listenerList, ptListener listener);
|
||||
void printListenerList(ptListenerList listenerList);
|
||||
void participateToConf(ptConf confChain, ptListener listenerChain, int confId, int listenerId);
|
||||
|
||||
#endif // CONF_H
|
||||
|
|
0
data/relations
Normal file
0
data/relations
Normal file
|
@ -78,3 +78,13 @@ void saveListeners(ptListener listenerChain) {
|
|||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void saveRelations(ptConf confChain) {
|
||||
FILE *file = fopen("./data/relations", "w");
|
||||
ptListener px = listenerChain;
|
||||
while(px -> next != NULL){
|
||||
fprintf(file,"%d,%s,%d,%d\n",px -> id,px -> name,px -> age,px -> level);
|
||||
px = px -> next;
|
||||
}
|
||||
fclose(file);
|
||||
}
|
BIN
main.exe
BIN
main.exe
Binary file not shown.
|
@ -99,7 +99,11 @@ void menuConf(ptConf confChain, ptListener listenerChain) {
|
|||
|
||||
while (px -> next != NULL) {
|
||||
printf("id : %d\ntitle : %s\nspeaker : %s\n", px -> id, px -> title, px -> speaker);
|
||||
printf("%d/%d/%d\n\n",px -> day, px -> month, px -> year);
|
||||
printf("%d/%d/%d\n",px -> day, px -> month, px -> year);
|
||||
if (px -> listeners -> next != NULL ) {
|
||||
printListenerList(px -> listeners);
|
||||
}
|
||||
printf("\n");
|
||||
px = px -> next;
|
||||
}
|
||||
system("pause");
|
||||
|
@ -168,7 +172,11 @@ void menuAbo(ptConf confChain, ptListener listenerChain) {
|
|||
ptListener py = listenerChain;
|
||||
|
||||
while (py -> next != NULL) {
|
||||
printf("id : %d\nname: %s\nage: %d\nlevel: %d", py -> id, py -> name, py -> age, py -> level);
|
||||
printf("id : %d\nname: %s\nage: %d\nlevel: %d\n", py -> id, py -> name, py -> age, py -> level);
|
||||
if (py -> confs -> next != NULL) {
|
||||
printConfList(py -> confs);
|
||||
}
|
||||
printf("\n");
|
||||
py = py -> next;
|
||||
}
|
||||
system("pause");
|
||||
|
@ -198,7 +206,7 @@ void menuAbo(ptConf confChain, ptListener listenerChain) {
|
|||
{
|
||||
int id;
|
||||
|
||||
printf("Id de l'abonné à supprimer : ");
|
||||
printf("Id de l'abonne à supprimer : ");
|
||||
scanf("%d", &id);
|
||||
|
||||
removeListener(listenerChain, id);
|
||||
|
@ -237,7 +245,17 @@ void menu(ptConf confChain, ptListener listenerChain)
|
|||
break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
int confId, listenerId;
|
||||
printf("Entrez l'ID de la conference : ");
|
||||
scanf("%d", &confId);
|
||||
printf("Entrez l'ID du participant : ");
|
||||
scanf("%d", &listenerId);
|
||||
|
||||
participateToConf(confChain, listenerChain, confId, listenerId);
|
||||
menu(confChain, listenerChain);
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue