commit
This commit is contained in:
parent
3e73277764
commit
50efd5be5a
6 changed files with 90 additions and 19 deletions
60
conf.c
60
conf.c
|
@ -44,6 +44,36 @@ void addConf(ptConf confChain, int id, char title[], char speaker[], int day, in
|
||||||
px -> next -> next = NULL;
|
px -> next -> next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeConf(ptConf confChain, int id) {
|
||||||
|
ptConf px = confChain;
|
||||||
|
|
||||||
|
if (px -> next -> next == NULL) {
|
||||||
|
free(px -> next);
|
||||||
|
px -> next = NULL;
|
||||||
|
} else if (px -> id == id) {
|
||||||
|
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) {
|
||||||
|
px = px -> next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (px -> next -> id == id) {
|
||||||
|
ptConf tmp = px -> next;
|
||||||
|
px -> next = px -> next -> next;
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int findListenerId(ptListener listenerChain) {
|
int findListenerId(ptListener listenerChain) {
|
||||||
ptListener px = listenerChain;
|
ptListener px = listenerChain;
|
||||||
int max = 0;
|
int max = 0;
|
||||||
|
@ -84,3 +114,33 @@ void addListener(ptListener listenerChain, int id, char name[], int age, int lev
|
||||||
px -> next -> next = NULL;
|
px -> next -> next = NULL;
|
||||||
px -> next -> prev = px;
|
px -> next -> prev = px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeListener(ptListener listenerChain, int id) {
|
||||||
|
ptListener px = listenerChain;
|
||||||
|
|
||||||
|
if (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) {
|
||||||
|
px = px -> next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (px -> next -> id == id) {
|
||||||
|
ptListener tmp = px -> next;
|
||||||
|
px -> next = px -> next -> next;
|
||||||
|
px -> next -> prev = px;
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
conf.h
2
conf.h
|
@ -42,8 +42,10 @@ typedef tListenerList* ptListenerList;
|
||||||
int findConfId(ptConf confChain);
|
int findConfId(ptConf confChain);
|
||||||
ptConf newConfChain();
|
ptConf newConfChain();
|
||||||
void addConf(ptConf confChain, int id, 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);
|
||||||
|
void removeConf(ptConf confChain, int id);
|
||||||
int findListenerId(ptListener listenerChain);
|
int findListenerId(ptListener listenerChain);
|
||||||
ptListener newListenerChain();
|
ptListener newListenerChain();
|
||||||
void addListener(ptListener listenerChain, int id, char name[], int age, int level);
|
void addListener(ptListener listenerChain, int id, char name[], int age, int level);
|
||||||
|
void removeListener(ptListener listenerChain, int id);
|
||||||
|
|
||||||
#endif // CONF_H
|
#endif // CONF_H
|
||||||
|
|
10
data/confs
10
data/confs
|
@ -1,10 +0,0 @@
|
||||||
1,coucou mes copains,Jean-Pierre,25,12,2023
|
|
||||||
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,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
|
|
|
@ -1 +1 @@
|
||||||
1,Jose,26,4
|
1,jose,12,3
|
||||||
|
|
BIN
main.exe
BIN
main.exe
Binary file not shown.
|
@ -125,12 +125,23 @@ void menuConf(ptConf confChain, ptListener listenerChain) {
|
||||||
scanf("%d", &year);
|
scanf("%d", &year);
|
||||||
|
|
||||||
addConf(confChain, id, title, speaker, day, month, year);
|
addConf(confChain, id, title, speaker, day, month, year);
|
||||||
|
saveConf(confChain);
|
||||||
menuConf(confChain, listenerChain);
|
menuConf(confChain, listenerChain);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
|
||||||
|
printf("Id de la conference à supprimer : ");
|
||||||
|
scanf("%d", &id);
|
||||||
|
|
||||||
|
removeConf(confChain, id);
|
||||||
|
saveConf(confChain);
|
||||||
|
menuConf(confChain, listenerChain);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
menu(confChain, listenerChain);
|
menu(confChain, listenerChain);
|
||||||
|
@ -157,11 +168,11 @@ void menuAbo(ptConf confChain, ptListener listenerChain) {
|
||||||
ptListener py = listenerChain;
|
ptListener py = listenerChain;
|
||||||
|
|
||||||
while (py -> next != NULL) {
|
while (py -> next != NULL) {
|
||||||
printf("name: %s\nage: %d\nlevel: %d", py -> name, py -> age, py -> level);
|
printf("id : %d\nname: %s\nage: %d\nlevel: %d", py -> id, py -> name, py -> age, py -> level);
|
||||||
py = py -> next;
|
py = py -> next;
|
||||||
}
|
}
|
||||||
system("pause");
|
system("pause");
|
||||||
menuConf(confChain, listenerChain);
|
menuAbo(confChain, listenerChain);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -178,12 +189,23 @@ void menuAbo(ptConf confChain, ptListener listenerChain) {
|
||||||
scanf("%d", &level);
|
scanf("%d", &level);
|
||||||
|
|
||||||
addListener(listenerChain, id, name, age, level);
|
addListener(listenerChain, id, name, age, level);
|
||||||
|
saveListeners(listenerChain);
|
||||||
menuAbo(confChain, listenerChain);
|
menuAbo(confChain, listenerChain);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
|
||||||
|
printf("Id de l'abonné à supprimer : ");
|
||||||
|
scanf("%d", &id);
|
||||||
|
|
||||||
|
removeListener(listenerChain, id);
|
||||||
|
saveListeners(listenerChain);
|
||||||
|
menuAbo(confChain, listenerChain);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
menu(confChain, listenerChain);
|
menu(confChain, listenerChain);
|
||||||
|
@ -196,10 +218,10 @@ void menuAbo(ptConf confChain, ptListener listenerChain) {
|
||||||
|
|
||||||
void menu(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/ Sauvegarder", "7/ 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/ Quitter"};
|
||||||
system("cls");
|
system("cls");
|
||||||
drawMenu(options, 7);
|
drawMenu(options, 6);
|
||||||
goToCoords(0, 15);
|
goToCoords(0, 14);
|
||||||
printf("Que voulez-vous faire ? : ");
|
printf("Que voulez-vous faire ? : ");
|
||||||
int choice;
|
int choice;
|
||||||
scanf("%d", &choice);
|
scanf("%d", &choice);
|
||||||
|
@ -224,9 +246,6 @@ void menu(ptConf confChain, ptListener listenerChain)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
saveConf(confChain);
|
|
||||||
saveListeners(listenerChain);
|
|
||||||
menu(confChain, listenerChain);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue