diff --git a/conf.c b/conf.c index 7699dda..14f5a05 100644 --- a/conf.c +++ b/conf.c @@ -26,20 +26,20 @@ ptConf newConfChain() { return confChain; } -void addConf(ptConf confChain, char title[], char speaker[], int day, int month, int year) { +void addConf(ptConf confChain, int id, char title[], char speaker[], int day, int month, int year) { ptConf px = confChain; while (px -> next != NULL) { px = px -> next; } - px -> id = findConfId(confChain); + px -> id = id; px -> day = day; px -> month = month; px -> year = year; strcpy(px -> title, title); strcpy(px -> speaker, speaker); - // ajouter le builder de liste de participants + px -> listeners = (ptListenerList) malloc(sizeof(tListenerList)); px -> next = (ptConf) malloc(sizeof(tConf)); px -> next -> next = NULL; } @@ -68,18 +68,18 @@ ptListener newListenerChain() { return listenerChain; } -void addListener(ptListener listenerChain, char name[], int age, int level) { +void addListener(ptListener listenerChain, int id, char name[], int age, int level) { ptListener px = listenerChain; while (px -> next != NULL) { px = px -> next; } - px -> id = findListenerId(listenerChain); + px -> id = id; strcpy(px -> name, name); px -> age = age; px -> level = level; - // ajouter la liste de conférences + px -> confs = (ptConfList) malloc(sizeof(tConfList)); px -> next = (ptListener) malloc(sizeof(tListener)); px -> next -> next = NULL; px -> next -> prev = px; diff --git a/conf.h b/conf.h index d48ade3..df182db 100644 --- a/conf.h +++ b/conf.h @@ -39,9 +39,11 @@ typedef tListener* ptListener; typedef tConfList* ptConfList; typedef tListenerList* ptListenerList; +int findConfId(ptConf confChain); ptConf newConfChain(); -void addConf(ptConf confChainStart, char title[], char speaker[], int day, int month, int year); +void addConf(ptConf confChain, int id, char title[], char speaker[], int day, int month, int year); +int findListenerId(ptListener listenerChain); ptListener newListenerChain(); -void addListener(ptListener listenerChain, char name[], int age, int level); +void addListener(ptListener listenerChain, int id, char name[], int age, int level); #endif // CONF_H diff --git a/data/confs b/data/confs index 3389fa3..fd141d3 100644 --- a/data/confs +++ b/data/confs @@ -2,18 +2,9 @@ 2,coucou mes copains,Jean-Pierre,25,12,2023 3,coucou mes copains,Jean-Pierre,25,12,2023 4,coucou mes copains,Jean-Pierre,25,12,2023 -5,test,tesst,21,120,2023 -6,test,tesst,21,120,2023 -7,test,tesst,21,120,2023 -8,test,tesst,21,120,2023 -9,test,tesst,21,120,2023 -10,test,tesst,21,120,2023 -11,test,tesst,21,120,2023 -12,test,tesst,21,120,2023 -13,test,tesst,21,120,2023 -14,test,tesst,21,120,2023 -15,test,tesst,21,120,2023 -16,test,tesst,21,120,2023 -17,test,tesst,21,120,2023 -18,test,tesst,21,120,2023 -19,test,tesst,21,120,2023 +5,la,belle,6422476,762406370,6422132 +6,la,belle,6422476,-26872523,6422132 +7,e,e,22,7,2004 +8,Test,de,6422476,-1123880272,6422132 +9,Test,a,6422476,-2011631347,6422132 +10,test,test,1,1,1 diff --git a/data/listeners b/data/listeners index a85b07f..e69de29 100644 --- a/data/listeners +++ b/data/listeners @@ -1,3 +0,0 @@ -1,Roger,19,4 -2,Roger,19,4 -3,Roger,19,4 diff --git a/fileManager.c b/fileManager.c index 8c7b2eb..a6e71fb 100644 --- a/fileManager.c +++ b/fileManager.c @@ -25,7 +25,7 @@ void readConfs(ptConf confChain) { token = strtok(NULL, ","); } - addConf(confChain, tokens[1], tokens[2], atoi(tokens[3]), atoi(tokens[4]), atoi(tokens[5])); + addConf(confChain, atoi(tokens[0]), tokens[1], tokens[2], atoi(tokens[3]), atoi(tokens[4]), atoi(tokens[5])); } fclose(file); diff --git a/fileManager.h b/fileManager.h index 9be61c1..a85a8e3 100644 --- a/fileManager.h +++ b/fileManager.h @@ -3,7 +3,7 @@ #include "conf.h" -void readConfs(); +void readConfs(ptConf confChain); void saveConf(ptConf confChain); void saveListeners(ptListener listenerChain); diff --git a/main.c b/main.c index 99b44ec..7351f94 100644 --- a/main.c +++ b/main.c @@ -10,19 +10,17 @@ int main() ptListener listenerChain = newListenerChain(); readConfs(confChain); - - addConf(confChain, "test", "tesst", 21, 120, 2023); - addConf(confChain, "test", "tesst", 21, 120, 2023); - addConf(confChain, "test", "tesst", 21, 120, 2023); - - addListener(listenerChain, "Roger", 19, 4); - addListener(listenerChain, "Roger", 19, 4); - addListener(listenerChain, "Roger", 19, 4); - menu(confChain, listenerChain); - saveConf(confChain); saveListeners(listenerChain); + + /*addConf(confChain, "test", "tesst", 21, 120, 2023); + addConf(confChain, "test", "tesst", 21, 120, 2023); + addConf(confChain, "test", "tesst", 21, 120, 2023); + + addListener(listenerChain, "Roger", 19, 4); + addListener(listenerChain, "Roger", 19, 4); + addListener(listenerChain, "Roger", 19, 4);*/ return 0; } \ No newline at end of file diff --git a/main.exe b/main.exe index b9d60c4..1d28040 100644 Binary files a/main.exe and b/main.exe differ diff --git a/screenManager.c b/screenManager.c index cc95601..228ca7a 100644 --- a/screenManager.c +++ b/screenManager.c @@ -98,7 +98,7 @@ void menuConf(ptConf confChain, ptListener listenerChain) { ptConf px = confChain; while (px -> next != NULL) { - printf("title : %s\nspeaker : %s\n", px -> title, px -> speaker); + 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); px = px -> next; } @@ -107,7 +107,27 @@ void menuConf(ptConf confChain, ptListener listenerChain) { break; case 2: + { + int id, day, month, year; + char title[30]; + char speaker[20]; + + id = findConfId(confChain); + printf("Titre de la conference : "); + scanf("%29s", &title); + printf("Nom du conferencier : "); + scanf("%19s", &speaker); + printf("Jour : "); + scanf("%d", &day); + printf("Mois : "); + scanf("%d", &month); + printf("Année : "); + scanf("%d", &year); + + addConf(confChain, id, title, speaker, day, month, year); + menuConf(confChain, listenerChain); break; + } case 3: break; @@ -146,7 +166,22 @@ void menuAbo(ptConf confChain, ptListener listenerChain) { break; case 2: + { + int id, age, level; + char name[20]; + + id = findListenerId(listenerChain); + printf("Nom : "); + scanf("%19s", &name); + printf("Age : "); + scanf("%d", &age); + printf("Niveau : "); + scanf("%d", &level); + + addListener(listenerChain, id, name, age, level); + menuAbo(confChain, listenerChain); break; + } case 3: break; @@ -163,10 +198,10 @@ void menuAbo(ptConf confChain, ptListener listenerChain) { void menu(ptConf confChain, ptListener listenerChain) { - char *options[] = {"1/ Gestion des conferences", "2/ Gestion des abonnes", "3/ Participer a une conference", "4/ Voir la meilleure conference", "5/ Voir la participation a une conference", "6/ Quitter"}; + char *options[] = {"1/ Gestion des conferences", "2/ Gestion des abonnes", "3/ Participer a une conference", "4/ Voir la meilleure conference", "5/ Voir la participation a une conference", "6/ Sauvegarder", "7/ Quitter"}; system("cls"); - drawMenu(options, 6); - goToCoords(0, 14); + drawMenu(options, 7); + goToCoords(0, 15); printf("Que voulez-vous faire ? : "); int choice; scanf("%d", &choice); @@ -191,6 +226,9 @@ void menu(ptConf confChain, ptListener listenerChain) break; case 6: + saveConf(confChain); + saveListeners(listenerChain); + menu(confChain, listenerChain); break; default: