From caaf0af3c34f0efa424ce93bd62b3b01b3be8f54 Mon Sep 17 00:00:00 2001 From: "martin.bonetti" <1martinbonetti@gmail.com> Date: Sat, 12 Nov 2022 00:01:16 +0100 Subject: [PATCH] added NouvelAdherent, still load of errors and missing functions tho --- .vscode/tasks.json | 28 +++++ Adherents.txt | 12 +-- SAE.c | 251 ++++++++++++++++++++++++++------------------- SAE.h | 7 +- TestSAE.c | 4 +- 5 files changed, 188 insertions(+), 114 deletions(-) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..136d521 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: gcc générer le fichier actif", + "command": "/usr/bin/gcc", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Tâche générée par le débogueur." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/Adherents.txt b/Adherents.txt index c2a42f7..f710599 100644 --- a/Adherents.txt +++ b/Adherents.txt @@ -1,6 +1,6 @@ -1504 50 -8642 420 -6824 06 -3213 23 -8419 82 -1355 54 +1504 50 15 +8642 420 60 +6824 06 45 +3213 23 25 +8419 82 45 +1355 54 80 diff --git a/SAE.c b/SAE.c index 42e7faf..c1416a8 100755 --- a/SAE.c +++ b/SAE.c @@ -2,131 +2,176 @@ #include "SAE.h" #define LEN 100 -int chargementClients(int *t1, int *t2, int tmax){ //charge les tableaux -FILE *fe; -int numClient, points; -fe=fopen("Adherents.txt","r"); -if(fe==NULL){ - printf("Probleme ouverture fichier"); -return -1;} -int i=0; -fscanf("%d%*c %d%*c",&numClient,&points); -while(feof(fe)==0){ - if(i>tmax){ - printf("taille du tableau dépassée \n"); +int chargementClients(int* t1, int* t2, int* t3, int tmax){ //charge les tableaux + FILE *fe; + int numClient, points,ptsDepense; + fe=fopen("Adherents.txt","r"); + if(fe==NULL){ + printf("Probleme ouverture fichier"); + return -1;} + int i=0; + fscanf("%d%*c %d%*c %d%*c",&numClient,&points,&ptsDepense); + while(feof(fe)==0){ + if(i>tmax){ + printf("taille du tableau dépassée \n"); + fclose(fe); + return-1;} + t1[i]=numClient; + t2[i]=points; + t3[i]=ptsDepense; + fscanf("%d%*c %d%*c %d%*c",&numClient,&points,&ptsDepense); + i++; + } fclose(fe); - return-1;} - t1[i]=numClient; - t2[i]=points; - fscanf("%d%*c %d%*c",&numClient,&points); - i++; - } - fclose(fe); - return i; + return i; } -int rechercheAdherent(int *t1, int *t2,int val,int LENlo,int *trouve){//recherche un adherent et affiche sont identifiant -int i; -for (i=0;i=100){ + printf("Vous avez gagné 10pts bonus."); + t3[i]=t3[i]-100; + t2[i]=t2[i]+10; + } + } + return 0; } void DonneesAdherent(int *t1, int *t2){ -int id,trouve,rech,points; -printf("Saisir un identifiant:"); -scanf("%d",&id); -rech=rechercheAdherent(t1,t2,id,LEN,&trouve); -points=t2[rech]; -printf("Vous êtes l'adhérent %d, et vous avez %d points.",id,points); + int id,trouve,rech,points; + printf("Saisir un identifiant:"); + scanf("%d",&id); + rech=rechercheAdherent(t1,id,LEN,&trouve); + points=t2[rech]; + printf("Vous êtes l'adhérent %d, et vous avez %d points.",id,points); } -void CreditCarte(t1[],t2[]){ -int pts; -float prix; -printf("Saisir un nombre de points(10pts=5€)"); -scanf("%d",&pts); -while(pts!=>0){ -prix=pts*0.5; -printf("Voulez vous saisir plus de points?(10pts=5€)"); -scanf("%d",&pts);} -printf("Vous avez acheté %d pts pour %.2f €.",pts,prix); +void CreditCarte(int *t1, int*t2){ + int pts,i,trouve,id; + float prix; + printf("Saisir identifiant"); + scanf("%d",&id); + i=rechercheAdherent(t1,id,LEN,&trouve); + printf("Saisir un nombre de points(10pts=5€)"); + scanf("%d",&pts); + while(pts!=0){ + prix=pts*0.5; + t2[i]=t2[i]+pts; + printf("Voulez vous saisir plus de points?(10pts=5€)"); + scanf("%d",&pts);} + printf("Vous avez acheté %d pts pour %.2f €.",pts,prix); } +void NouvelAdherent(void){ + int *t1, *t2, *t3, tmax; + char ouinon; + printf("Voulez-vous créer un nouvel adhérent ? (o/n) : "); //demande de confirmation + scanf("%c%*c", &ouinon); + if (ouinon='o'){ + chargementClients(*t1, *t2, *t3, tmax); + t1[tmax+1] = t1[tmax] +1; + t2[tmax+1] = 0; + printf("un nouvel adhérent de n°%d à été créé"); + } + Admin; +} - - - - +void Bloquercarte(void){ + int *t1, *t2, *t3, tmax, *trouve; + char ouinon; + int carte; + printf("Entrez le numéro de la carte à bloquer : "); + scanf("%d", &carte); + chargementClients(*t1, *t2, *t3, tmax); + rechercheAdherent(*t1, carte, tmax, *trouve); + if (*trouve=0){printf("erreur, adhérent non trouvé");} + else(printf) +} diff --git a/SAE.h b/SAE.h index c426a39..1d0fab6 100644 --- a/SAE.h +++ b/SAE.h @@ -8,10 +8,11 @@ \brief:Gerer les adhérants d'un complexe sportif ainsi que leurs activités */ -int chargementClients(int *t1, int *t2,int tmax); -int rechercheAdherent(int *t1, int *t2,int val,int LENlo,int *trouve); +int chargementClients(int *t1, int *t2, int *t3, int tmax); +int rechercheAdherent(int *t1,int val,int LENlo,int *trouve); void choixAdmin(void); void Admin(void); void Adherent(void); -int ChoixActivite(int *t1, int *t2); +int ChoixActivite(int *t1, int *t2, int *t3); void DonneesAdherent(int *t1, int *t2); +void CreditCarte(int *t1, int *t2); diff --git a/TestSAE.c b/TestSAE.c index 9480aa8..9c26b19 100644 --- a/TestSAE.c +++ b/TestSAE.c @@ -1,8 +1,8 @@ #include "SAE.h" void testCode(void){ -int tAdherants[100],tPoints[100]; -chargementClients(tAdherants[100],tPoints[100],100); +int tAdherants[100],tPoints[100], tPointsbonus[100]; +chargementClients(tAdherants[100],tPoints[100],tPointsbonus[100], 100); choixAdmin; }