added NouvelAdherent, still load of errors and missing functions tho

master
martin.bonetti 2 years ago
parent 8a24f7c1ff
commit caaf0af3c3

28
.vscode/tasks.json vendored

@ -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"
}

@ -1,6 +1,6 @@
1504 50 1504 50 15
8642 420 8642 420 60
6824 06 6824 06 45
3213 23 3213 23 25
8419 82 8419 82 45
1355 54 1355 54 80

181
SAE.c

@ -2,131 +2,176 @@
#include "SAE.h" #include "SAE.h"
#define LEN 100 #define LEN 100
int chargementClients(int *t1, int *t2, int tmax){ //charge les tableaux int chargementClients(int* t1, int* t2, int* t3, int tmax){ //charge les tableaux
FILE *fe; FILE *fe;
int numClient, points; int numClient, points,ptsDepense;
fe=fopen("Adherents.txt","r"); fe=fopen("Adherents.txt","r");
if(fe==NULL){ if(fe==NULL){
printf("Probleme ouverture fichier"); printf("Probleme ouverture fichier");
return -1;} return -1;}
int i=0; int i=0;
fscanf("%d%*c %d%*c",&numClient,&points); fscanf("%d%*c %d%*c %d%*c",&numClient,&points,&ptsDepense);
while(feof(fe)==0){ while(feof(fe)==0){
if(i>tmax){ if(i>tmax){
printf("taille du tableau dépassée \n"); printf("taille du tableau dépassée \n");
fclose(fe); fclose(fe);
return-1;} return-1;}
t1[i]=numClient; t1[i]=numClient;
t2[i]=points; t2[i]=points;
fscanf("%d%*c %d%*c",&numClient,&points); t3[i]=ptsDepense;
fscanf("%d%*c %d%*c %d%*c",&numClient,&points,&ptsDepense);
i++; i++;
} }
fclose(fe); 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 rechercheAdherent(int *t1, int val, int LENlo, int *trouve){//recherche un adherent et affiche sont identifiant
int i; int i;
for (i=0;i<LENlo;i++){ for (i=0;i<LENlo;i++){
if (val==t1[i]){ if (val==t1[i]){
*trouve=0; *trouve=0;
return i;} return i;}
if (val<t1[i]){ if (val<t1[i]){
*trouve=1; *trouve=1;
return i;} return i;}
} }
return i; return i;
} }
void choixAdmin(void){//choix menu admin ou adherent void choixAdmin(void){//choix menu admin ou adherent
char admin; char admin;
printf("Êtes vous administrateur? (O/N)"); printf("Êtes vous administrateur? (O/N)");
scanf("%c%*c",&admin); scanf("%c%*c",&admin);
if(admin=='O') if(admin=='O')
Admin; Admin;
if(admin=='N') if(admin=='N')
Adherent; Adherent;
} }
void Admin(void){//menu admin void Admin(void){//menu admin
int choix; int choix;
printf("MENU: \n1)Nouvel adhérent \n2)Créditer une carte \n3)Bloquer une carte \n4)Réactiver une carte \n5)Afficher les données d'un adhérent \n"); printf("MENU: \n1)Nouvel adhérent \n2)Créditer une carte \n3)Bloquer une carte \n4)Réactiver une carte \n5)Afficher les données d'un adhérent \n6)Supprimer un adhérent");
scanf("%d",&choix); scanf("%d",&choix);
if(choix==1) if(choix==1)
NouvelAdherent; NouvelAdherent;
if(choix==2) if(choix==2)
CreditCarte; //en lien avec adherents CreditCarte; //en lien avec adherents
if(choix==3) if(choix==3)
Bloquercarte; Bloquercarte;
if(choix==4) if(choix==4)
RectiverCarte; RectiverCarte;
if(choix==5) if(choix==5)
DonneesAdherent;//en lien avec adherent DonneesAdherent;//en lien avec adherent
if(choix==6)
SupprimeAdherent;
} }
void Adherent(void){//menu adherent void Adherent(void){//menu adherent
int choix; int choix;
printf("MENU: \n1)Choix Activité \n2)Afficher les données d'un adhérent \n3)Créditer une carte \n"); printf("MENU: \n1)Choix Activité \n2)Afficher les données d'un adhérent \n3)Créditer une carte \n");
scanf("%d",&choix); scanf("%d",&choix);
if(choix==1) if(choix==1)
ChoixActivite; ChoixActivite;
if(choix==2) if(choix==2)
DonneesAdherent;//en lien avec admin DonneesAdherent;//en lien avec admin
if(choix==3) if(choix==3)
CreditCarte;//en lien avec admin CreditCarte;//en lien avec admin
} }
int ChoixActivite(int *t1, int *t2){//choix de l'activité int ChoixActivite(int *t1, int *t2,int *t3){//choix de l'activité
int activite,trouve,i; int activite,trouve,i,id;
printf("Choisissez une activité: \n1)VolleyBall(30pts) \n2)Natation(15pts) \n3)Randonnée(20pts) \n4)Escalade(35pts) \n"); printf("Choisissez une activité: \n1)VolleyBall(30pts) \n2)Natation(15pts) \n3)Randonnée(20pts) \n4)Escalade(35pts) \n");
scanf("%d",&activite); scanf("%d",&activite);
if(activite==1) printf("Saisirvotre identifiant");
scanf("%d",&id);
i=rechercheAdherent(t1,id,LEN, &trouve);
if(activite==1){
t2[i]=t2[i]-30; t2[i]=t2[i]-30;
if(activite==2) t3[i]=t3[i]+30;}
if(activite==2){
t2[i]=t2[i]-15; t2[i]=t2[i]-15;
if(activite==3) t3[i]=t3[i]+15;}
if(activite==3){
t2[i]=t2[i]-20; t2[i]=t2[i]-20;
if(activite==4) t3[i]=t3[i]+20;}
if(activite==4){
t2[i]=t2[i]-35; t2[i]=t2[i]-35;
if(t2[i]<0){ t3[i]=t3[i]+35;}
if(t2[i]<0){
printf("Erreur: crédit insuffisant."); printf("Erreur: crédit insuffisant.");
if(activite==1) if(activite==1){
t2[i]=t2[i]+30; t2[i]=t2[i]+30;
if(activite==2) t3[i]=t3[i]-30;}
if(activite==2){
t2[i]=t2[i]+15; t2[i]=t2[i]+15;
if(activite==3) t3[i]=t3[i]-15;}
if(activite==3){
t2[i]=t2[i]+20; t2[i]=t2[i]+20;
if(activite==4) t3[i]=t3[i]-20;}
if(activite==4){
t2[i]=t2[i]+35; t2[i]=t2[i]+35;
} t3[i]=t3[i]-35;}
return -1;
if (t3[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){ void DonneesAdherent(int *t1, int *t2){
int id,trouve,rech,points; int id,trouve,rech,points;
printf("Saisir un identifiant:"); printf("Saisir un identifiant:");
scanf("%d",&id); scanf("%d",&id);
rech=rechercheAdherent(t1,t2,id,LEN,&trouve); rech=rechercheAdherent(t1,id,LEN,&trouve);
points=t2[rech]; points=t2[rech];
printf("Vous êtes l'adhérent %d, et vous avez %d points.",id,points); printf("Vous êtes l'adhérent %d, et vous avez %d points.",id,points);
} }
void CreditCarte(t1[],t2[]){ void CreditCarte(int *t1, int*t2){
int pts; int pts,i,trouve,id;
float prix; float prix;
printf("Saisir un nombre de points(10pts=5€)"); printf("Saisir identifiant");
scanf("%d",&pts); scanf("%d",&id);
while(pts!=>0){ i=rechercheAdherent(t1,id,LEN,&trouve);
prix=pts*0.5; printf("Saisir un nombre de points(10pts=5€)");
printf("Voulez vous saisir plus de points?(10pts=5€)"); scanf("%d",&pts);
scanf("%d",&pts);} while(pts!=0){
printf("Vous avez acheté %d pts pour %.2f €.",pts,prix); 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)
}

@ -8,10 +8,11 @@
\brief:Gerer les adhérants d'un complexe sportif ainsi que leurs activités \brief:Gerer les adhérants d'un complexe sportif ainsi que leurs activités
*/ */
int chargementClients(int *t1, int *t2,int tmax); int chargementClients(int *t1, int *t2, int *t3, int tmax);
int rechercheAdherent(int *t1, int *t2,int val,int LENlo,int *trouve); int rechercheAdherent(int *t1,int val,int LENlo,int *trouve);
void choixAdmin(void); void choixAdmin(void);
void Admin(void); void Admin(void);
void Adherent(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 DonneesAdherent(int *t1, int *t2);
void CreditCarte(int *t1, int *t2);

@ -1,8 +1,8 @@
#include "SAE.h" #include "SAE.h"
void testCode(void){ void testCode(void){
int tAdherants[100],tPoints[100]; int tAdherants[100],tPoints[100], tPointsbonus[100];
chargementClients(tAdherants[100],tPoints[100],100); chargementClients(tAdherants[100],tPoints[100],tPointsbonus[100], 100);
choixAdmin; choixAdmin;
} }

Loading…
Cancel
Save