commit
This commit is contained in:
parent
c71dcffdf6
commit
7450b610cb
4 changed files with 100 additions and 29 deletions
43
conf.c
43
conf.c
|
@ -3,20 +3,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|
||||||
ptDate newDate(int day, int month, int year) {
|
|
||||||
ptDate date = (ptDate) malloc(sizeof(ptDate));
|
|
||||||
|
|
||||||
date -> day = day;
|
|
||||||
date -> month = month;
|
|
||||||
date -> year = year;
|
|
||||||
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
void printDate(ptDate date) {
|
|
||||||
printf("date : %d/%d/%d\n", date -> day, date -> month, date -> year);
|
|
||||||
}
|
|
||||||
|
|
||||||
ptConf newConfChain() {
|
ptConf newConfChain() {
|
||||||
ptConf confChain = (ptConf) malloc(sizeof(ptConf));
|
ptConf confChain = (ptConf) malloc(sizeof(ptConf));
|
||||||
|
|
||||||
|
@ -32,10 +18,37 @@ void addConf(ptConf confChainStart, char title[], char speaker[], int day, int m
|
||||||
px = px -> next;
|
px = px -> next;
|
||||||
}
|
}
|
||||||
|
|
||||||
px -> date = newDate(day, month, year);
|
px -> day = day;
|
||||||
|
px -> month = month;
|
||||||
|
px -> year = year;
|
||||||
strcpy(px -> title, title);
|
strcpy(px -> title, title);
|
||||||
strcpy(px -> speaker, speaker);
|
strcpy(px -> speaker, speaker);
|
||||||
// ajouter le builder de liste de participants
|
// ajouter le builder de liste de participants
|
||||||
px -> next = (ptConf) malloc(sizeof(ptConf));
|
px -> next = (ptConf) malloc(sizeof(ptConf));
|
||||||
px -> next -> next = NULL;
|
px -> next -> next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ptListener newListenerChain() {
|
||||||
|
ptListener listenerChain = (ptListener) malloc(sizeof(ptListener));
|
||||||
|
|
||||||
|
listenerChain -> prev = NULL;
|
||||||
|
listenerChain -> next = NULL;
|
||||||
|
|
||||||
|
return listenerChain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addListener(ptListener listenerChain, char name[], int age, int level) {
|
||||||
|
ptListener px = listenerChain;
|
||||||
|
|
||||||
|
while (px -> next != NULL) {
|
||||||
|
px = px -> next;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(px -> name, name);
|
||||||
|
px -> age = age;
|
||||||
|
px -> level = level;
|
||||||
|
// ajouter la liste de conférences
|
||||||
|
px -> next = (ptListener) malloc(sizeof(ptListener));
|
||||||
|
px -> next -> next = NULL;
|
||||||
|
px -> next -> prev = px;
|
||||||
|
}
|
21
conf.h
21
conf.h
|
@ -1,18 +1,15 @@
|
||||||
#ifndef CONF_H
|
#ifndef CONF_H
|
||||||
#define CONF_H
|
#define CONF_H
|
||||||
|
|
||||||
typedef struct date {
|
|
||||||
int day;
|
|
||||||
int month;
|
|
||||||
int year;
|
|
||||||
} tDate;
|
|
||||||
|
|
||||||
struct listenerList;
|
struct listenerList;
|
||||||
|
|
||||||
typedef struct conf {
|
typedef struct conf {
|
||||||
tDate *date;
|
struct date* date;
|
||||||
char title[30];
|
char title[30];
|
||||||
char speaker[20];
|
char speaker[20];
|
||||||
|
int day;
|
||||||
|
int month;
|
||||||
|
int year;
|
||||||
struct listenerList* listeners;
|
struct listenerList* listeners;
|
||||||
struct conf* next;
|
struct conf* next;
|
||||||
} tConf;
|
} tConf;
|
||||||
|
@ -26,8 +23,9 @@ typedef struct listener {
|
||||||
char name[20];
|
char name[20];
|
||||||
int age;
|
int age;
|
||||||
int level;
|
int level;
|
||||||
struct tConfList* confs;
|
struct confList* confs;
|
||||||
struct tListener* next;
|
struct listener* prev;
|
||||||
|
struct listener* next;
|
||||||
} tListener;
|
} tListener;
|
||||||
|
|
||||||
typedef struct listenerList {
|
typedef struct listenerList {
|
||||||
|
@ -35,15 +33,14 @@ typedef struct listenerList {
|
||||||
struct tListenerList* next;
|
struct tListenerList* next;
|
||||||
} tListenerList;
|
} tListenerList;
|
||||||
|
|
||||||
typedef tDate* ptDate;
|
|
||||||
typedef tConf* ptConf;
|
typedef tConf* ptConf;
|
||||||
typedef tListener* ptListener;
|
typedef tListener* ptListener;
|
||||||
typedef tConfList* ptConfList;
|
typedef tConfList* ptConfList;
|
||||||
typedef tListenerList* ptListenerList;
|
typedef tListenerList* ptListenerList;
|
||||||
|
|
||||||
ptDate newDate(int day, int month, int year);
|
|
||||||
void printDate(ptDate date);
|
|
||||||
ptConf newConfChain();
|
ptConf newConfChain();
|
||||||
void addConf(ptConf confChainStart, char title[], char speaker[], int day, int month, int year);
|
void addConf(ptConf confChainStart, char title[], char speaker[], int day, int month, int year);
|
||||||
|
ptListener newListenerChain();
|
||||||
|
void addListener(ptListener listenerChain, char name[], int age, int level);
|
||||||
|
|
||||||
#endif // CONF_H
|
#endif // CONF_H
|
BIN
main
BIN
main
Binary file not shown.
65
main.c
65
main.c
|
@ -5,11 +5,72 @@
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
ptConf confChain = newConfChain();
|
ptConf confChain = newConfChain();
|
||||||
|
ptListener listenerChain = newListenerChain();
|
||||||
|
|
||||||
|
addConf(confChain, "test", "tesst", 21, 120, 2023);
|
||||||
|
addConf(confChain, "test", "tesst", 21, 120, 2023);
|
||||||
addConf(confChain, "test", "tesst", 21, 120, 2023);
|
addConf(confChain, "test", "tesst", 21, 120, 2023);
|
||||||
|
|
||||||
printf("title : %s\nspeaker : %s\n", confChain -> title, confChain -> speaker);
|
//addListener(listenerChain, "Roger", 19, 4);
|
||||||
printDate(confChain -> date);
|
|
||||||
|
ptConf px = confChain;
|
||||||
|
|
||||||
|
while (px -> next != NULL) {
|
||||||
|
printf("title : %s\nspeaker : %s\n", px -> title, px -> speaker);
|
||||||
|
px = px -> next;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i=0,j=0;
|
||||||
|
|
||||||
|
////////////////////////// Menu 1 ////////////////////////////////
|
||||||
|
|
||||||
|
printf("\n 1/ Gestion des conferences\n 2/ Gestion des abonnes\n 3/ Participer a une conference");
|
||||||
|
printf("\n 4/ Voir la meilleure conference\n 5/ Voir la participation a une conference");
|
||||||
|
printf("\n 6/ Quitter\n");
|
||||||
|
|
||||||
|
|
||||||
|
scanf("%d",&i);
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
switch (i){
|
||||||
|
|
||||||
|
//////////////////////// Menu conf /////////////////////////
|
||||||
|
|
||||||
|
case 1:{
|
||||||
|
printf("\n 1/ Voir la liste des conferences\n 2/ Ajouter une conference \n 3/ Suprimer une conference\n 4/ Retour\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////// Menu abonne /////////////////////////
|
||||||
|
|
||||||
|
case 2: {
|
||||||
|
printf("\n 1/ Voir la liste des abonnes\n 2/ Ajouter un abonne \n 3/ Suprimer un abonne\n 4/ Retour\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 3: {
|
||||||
|
printf("\n Nom de l'abonne : \n Nom de la conference : \n Note de la conference : ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 4: {
|
||||||
|
printf("\n Nom : \n Note : ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case 5: {
|
||||||
|
printf("\n Entrer le nom de la conference : ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 6: {
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue