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;
|
||||
|
@ -143,4 +145,79 @@ void removeListener(ptListener listenerChain, int id) {
|
|||
free(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue