This commit is contained in:
Lukian 2023-11-12 21:36:26 +01:00
parent c71dcffdf6
commit 7450b610cb
4 changed files with 100 additions and 29 deletions

43
conf.c
View file

@ -3,20 +3,6 @@
#include <string.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 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 -> date = newDate(day, month, year);
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 -> next = (ptConf) malloc(sizeof(ptConf));
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
View file

@ -1,18 +1,15 @@
#ifndef CONF_H
#define CONF_H
typedef struct date {
int day;
int month;
int year;
} tDate;
struct listenerList;
typedef struct conf {
tDate *date;
struct date* date;
char title[30];
char speaker[20];
int day;
int month;
int year;
struct listenerList* listeners;
struct conf* next;
} tConf;
@ -26,8 +23,9 @@ typedef struct listener {
char name[20];
int age;
int level;
struct tConfList* confs;
struct tListener* next;
struct confList* confs;
struct listener* prev;
struct listener* next;
} tListener;
typedef struct listenerList {
@ -35,15 +33,14 @@ typedef struct listenerList {
struct tListenerList* next;
} tListenerList;
typedef tDate* ptDate;
typedef tConf* ptConf;
typedef tListener* ptListener;
typedef tConfList* ptConfList;
typedef tListenerList* ptListenerList;
ptDate newDate(int day, int month, int year);
void printDate(ptDate date);
ptConf newConfChain();
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

BIN
main

Binary file not shown.

65
main.c
View file

@ -5,11 +5,72 @@
int main()
{
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);
printf("title : %s\nspeaker : %s\n", confChain -> title, confChain -> speaker);
printDate(confChain -> date);
//addListener(listenerChain, "Roger", 19, 4);
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;
}