Fusion de tout ce qu'on a fait, modification de Client Venu pour ajouter la réduction par age, ajout des noms pour chaque sport et quelques autres petits changements

master
Renaud BEURET 2 years ago
parent b44dcf4bb1
commit cebdc8caf0

@ -1,2 +1,3 @@
100 P J 52 1 42 100 56 55 52 1 42
101 D F 18 0 51 102 55 55 25 1 117
103 55 56 30 1 3

295
saeN.c

@ -5,17 +5,40 @@
void chargementInit (void) void chargementInit (void)
{ {
int idSports[TAILLE], nbPtSpo[TAILLE], nSports, choix/*nb de sports, choix*/; int idSports[TAILLE], nbPtSpo[TAILLE], nSports, choix;/*nb de sports, choix*/;
int tNC[50], tA[50], tCA[50], tPO[50]; //pour tes fonctions int tNC[50], tA[50], tCA[50], tPO[50]; //pour tes fonctions
int nAdherent; /*nb d'adherents*/ //J'ai enlevé Tmax vu que j'avais déjà define TAILLE à 50 , mais faudra probablement y changer vu que ça fait pas bcp 50 adhérents int nAdherent; /*nb d'adherents*/ //J'ai enlevé Tmax vu que j'avais déjà define TAILLE à 50 , mais faudra probablement y changer vu que ça fait pas bcp 50 adhérents
char tN[50],tPR[50],venu[50] = {0}; char tN[50],tPR[50],venu[50] = {0}, listeSports[50][20];
nSports = chargementSport(idSports,nbPtSpo,TAILLE); nSports = chargementSport(idSports,nbPtSpo,TAILLE,listeSports);
nAdherent = chargementadherent(tNC,tN,tPR,tA,tCA,tPO,TAILLE); nAdherent = chargementadherent(tNC,tN,tPR,tA,tCA,tPO);
choixMenu(choix,idSports,nbPtSpo,&nSports,tNC,tA,tCA,tPO,&nAdherent,tN,tPR,venu); printf("\nBienvenue , veuillez choisir le type d'action que vous voulez faire \n");
return; menuChoix(choix,idSports,nbPtSpo,&nSports,tNC,tA,tCA,tPO,&nAdherent,tN,tPR,venu,listeSports);
} }
int choixMenu (int choix, int *idSports, int *nbPtSpo, int *nSports, int *tNC, int *tA, int *tCA, int *tPO, int *nAdherent, char *tN, char *tPR, char *venu) int menuChoix (int choix, int *idSports, int *nbPtSpo, int *nSports, int *tNC, int *tA, int *tCA, int *tPO, int *nAdherent, char *tN, char *tPR, char *venu, char listeSports[][20])
{
printf("------------------------------------------------\n"); //tableau qui s'affiche en premier pour choisir
printf("| Choix de la gestion |\n");
printf("| |\n");
printf("| 1. Gestion des activités |\n");
printf("| 2. Gestion des adhérents |\n");
printf("| |\n"); //espace libre , vérifie que ça s'affiche bien en testant si tu y change (tu peux toujours rajouter plus de fonctions stv)
printf("| 9. Quitter |\n");
printf("| |\n");
printf("------------------------------------------------\n"); //tableau qui s'affiche en premier pour choisir
printf("Rentrez un chiffre : \n"); //choix de l'option
scanf("%d%*c",&choix);
if (choix == 1)
{printf("\n");choixMenuAct(choix,idSports,nbPtSpo,nSports,tNC,tA,tCA,tPO,nAdherent,tN,tPR,venu,listeSports);return 0;}
if (choix == 2)
{printf("\n");choixMenuAd(choix,idSports,nbPtSpo,nSports,tNC,tA,tCA,tPO,nAdherent,tN,tPR,venu,listeSports);return 0;}
if (choix == 9) //quitte le logiciel si l'utilisateur a rentré 9
{printf("\n"); printf("Arrêt du logiciel");printf("\n"); printf("\n");}
if (choix != 9)
menuChoix (choix,idSports,nbPtSpo,nSports,tNC,tA,tCA,tPO,nAdherent,tN,tPR,venu,listeSports);
}
int choixMenuAct (int choix, int *idSports, int *nbPtSpo, int *nSports, int *tNC, int *tA, int *tCA, int *tPO, int *nAdherent, char *tN, char *tPR, char *venu, char listeSports[][20])
{ {
printf("------------------------------------------------\n"); //tableau qui s'affiche en premier pour choisir printf("------------------------------------------------\n"); //tableau qui s'affiche en premier pour choisir
printf("| Gestion des activités |\n"); printf("| Gestion des activités |\n");
@ -24,38 +47,61 @@ int choixMenu (int choix, int *idSports, int *nbPtSpo, int *nSports, int *tNC, i
printf("| 2. Ajout d'une Activité |\n"); printf("| 2. Ajout d'une Activité |\n");
printf("| 3. Suppression d'une Activité |\n"); printf("| 3. Suppression d'une Activité |\n");
printf("| 4. Changer le prix d'une activité |\n"); printf("| 4. Changer le prix d'une activité |\n");
printf("| 5. Afficher les adhérents |\n"); printf("| |\n");
printf("| 6. Ajouter un adhérent |\n");
printf("| 7. Arrivée d'un client |\n"); //espace libre , vérifie que ça s'affiche bien en testant si tu y change
printf("| |\n"); //espace libre , vérifie que ça s'affiche bien en testant si tu y change (tu peux toujours rajouter plus de fonctions stv)
printf("| 9. Quitter |\n"); printf("| 9. Quitter |\n");
printf("| |\n"); printf("| |\n");
printf("------------------------------------------------\n"); //tableau qui s'affiche en premier pour choisir printf("------------------------------------------------\n"); //tableau qui s'affiche en premier pour choisir
printf("Rentrez un chiffre : \n"); //choix de l'option printf("Rentrez un chiffre : \n"); //choix de l'option
scanf("%d%*c",&choix); scanf("%d%*c",&choix);
if (choix == 1) if (choix == 1)
{printf("\n");affichage(idSports,nbPtSpo,*nSports); printf("\n");} {printf("\n");affichage(idSports,nbPtSpo,*nSports,listeSports); printf("\n");}
if (choix == 2) if (choix == 2)
{printf("\n");ajoutSport(idSports,nbPtSpo,nSports,TAILLE); printf("\n");} {printf("\n");ajoutSport(idSports,nbPtSpo,nSports,TAILLE,listeSports); printf("\n");}
if (choix == 3) if (choix == 3)
{printf("\n");enlèveSport(idSports,nbPtSpo,nSports);printf("\n");} {printf("\n");enlèveSport(idSports,nbPtSpo,nSports,listeSports);printf("\n");}
if (choix == 4) if (choix == 4)
{printf("\n");changprix(idSports,nbPtSpo,*nSports);printf("\n");} {printf("\n");changprix(idSports,nbPtSpo,*nSports);printf("\n");}
if (choix == 5)
{printf("\n");affichageA(tNC,tN,tPR,tA,tCA,tPO,*nAdherent);printf("\n");}
if (choix == 6)
{printf("\n");/*Quand t'aura fait la fonction*/;printf("\n");}
if (choix == 7)
{printf("\n");clientVenu(tNC,tCA,tPO,idSports,nbPtSpo,venu);printf("\n");}
if (choix == 9) //quitte le logiciel si l'utilisateur a rentré 9 if (choix == 9) //quitte le logiciel si l'utilisateur a rentré 9
{printf("\n"); printf("Arrêt du logiciel"); printf("\n"); printf("\n");} {printf("\n"); printf("Arrêt du logiciel"); printf("\n"); printf("\n");}
if (choix != 9) if (choix != 9)
choixMenu (choix,idSports,nbPtSpo,nSports,tNC,tA,tCA,tPO,nAdherent,tN,tPR,venu); menuChoix (choix,idSports,nbPtSpo,nSports,tNC,tA,tCA,tPO,nAdherent,tN,tPR,venu,listeSports);
sauvegardeSports(idSports,nbPtSpo,*nSports); sauvegardeSports(idSports,nbPtSpo,*nSports,listeSports);
return 0; return 0;
} }
int chargementadherent(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int Tmax) //j'ai renommé la fonction car c'est le plus le chargement que la création int choixMenuAd (int choix, int *idSports, int *nbPtSpo, int *nSports, int *tNC, int *tA, int *tCA, int *tPO, int *nAdherent, char *tN, char *tPR, char *venu, char listeSports[][20])
{
printf("-------------------------------------------------\n"); //tableau qui s'affiche en premier pour choisir
printf("| Gestion des adhérents |\n");
printf("| |\n");
printf("| 1. Afficher les adhérents |\n");
printf("| 2. Ajouter un adhérent |\n");
printf("| 3. Arrivée d'un client |\n");
printf("| 4. Ajout de points |\n");
printf("| 5. Suppression d'un adhérent |\n");
printf("| |\n");
printf("| 9. Quitter |\n");
printf("| |\n");
printf("--------------------------------------------------\n"); //tableau qui s'affiche en premier pour choisir
printf("Rentrez un chiffre : \n"); //choix de l'option
scanf("%d%*c",&choix);
if (choix == 1)
{printf("\n");affichageA(tNC,tN,tPR,tA,tCA,tPO,*nAdherent);printf("\n");}
if (choix == 2)
{printf("\n");insertpers(tNC,tN,tPR,tA,tCA,tPO,nAdherent);printf("\n");}
if (choix == 3)
{printf("\n");clientVenu(tNC,tCA,tPO,tA,idSports,nbPtSpo,venu);printf("\n");}
if (choix == 4)
{printf("\n");rajouteDpoints(tNC,tPO,nAdherent);printf("\n");}
if (choix == 5)
{printf("\n");supprpers(tNC,tN,tPR,tA,tCA,tPO,nAdherent);printf("\n");}
if (choix == 9) //quitte le logiciel si l'utilisateur a rentré 9
{printf("\n"); printf("Arrêt du logiciel"); printf("\n"); printf("\n");}
if (choix != 9)
{menuChoix (choix,idSports,nbPtSpo,nSports,tNC,tA,tCA,tPO,nAdherent,tN,tPR,venu,listeSports);return 0;}
}
int chargementadherent(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO) //j'ai renommé la fonction car c'est le plus le chargement que la création
{ {
int NC,N,PR,A,CA,PO, i=0; int NC,N,PR,A,CA,PO, i=0;
FILE *fe; FILE *fe;
@ -69,10 +115,10 @@ int chargementadherent(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, in
fscanf(fe,"%d %s %s %d %d %d",&NC,&N,&PR,&A,&CA,&PO); fscanf(fe,"%d %s %s %d %d %d",&NC,&N,&PR,&A,&CA,&PO);
while (!feof(fe)) while (!feof(fe))
{ {
if(i==Tmax) if(i==TAILLE)
{ {
printf("%d \t %d\n",i, Tmax); printf("%d \t %d\n",i, TAILLE);
printf("capasité atteinte\n"); printf("capacité atteinte\n");
fclose(fe); fclose(fe);
return -1; return -1;
} }
@ -84,30 +130,32 @@ int chargementadherent(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, in
tPO[i]=PO; tPO[i]=PO;
i++; i++;
fscanf(fe,"%d %s %s %d %d %d",&NC,&N,&PR,&A,&CA,&PO); fscanf(fe,"%d %s %s %d %d %d",&NC,&N,&PR,&A,&CA,&PO);
} }
fclose(fe); fclose(fe);
return i; return i;
} }
int clientVenu (int *tNC, int *tCA, int *tPO, int *idSports, int *nbPtSpo, char *venu) int clientVenu (int *tNC, int *tCA, int *tPO, int *tA, int *idSports, int *nbPtSpo, char *venu)
{ {
int arrive, position, positionSpo, activité; int arrive, position, positionSpo, activité, prix;
char trouvoupas, creation, nvAct = 'O'; char trouvoupas, creation, nvAct = 'O';
printf("Quel client est arrivé ?\n"); printf("Quel client est arrivé ?\n");
scanf("%d%*c",&arrive); scanf("%d%*c",&arrive);
position = recherche(tNC,TAILLE,arrive,&trouvoupas); position = rechercheSport(tNC,TAILLE,arrive,&trouvoupas);
if (tCA[position] == 0)
{
printf("La carte du client est désactivée\n");
return -1;
}
if (venu[position] == 'O') if (venu[position] == 'O')
{ {
printf("Erreur, le client est déjà venu aujourd'hui"); printf("Erreur, le client est déjà venu aujourd'hui\n");
return -1; return -1;
} }
if (trouvoupas == 'N') if (trouvoupas == 'N')
{ {
printf("Erreur, le client n'existe pas, voulez vous le créer ?\n"); printf("Erreur, le client n'existe pas\n");
scanf("%c%*c",&creation);
if (creation == 'O')
{/*Mettre la fonction ajouter un adhérent*/ return 0;}
else
return 0; return 0;
} }
if (trouvoupas == 'O') if (trouvoupas == 'O')
@ -116,18 +164,23 @@ int clientVenu (int *tNC, int *tCA, int *tPO, int *idSports, int *nbPtSpo, char
{ {
printf("Quelle activité va t-il faire ?\n"); printf("Quelle activité va t-il faire ?\n");
scanf("%d%*c",&activité); scanf("%d%*c",&activité);
positionSpo = recherche(idSports,TAILLE,activité,&trouvoupas); positionSpo = rechercheSport(idSports,TAILLE,activité,&trouvoupas);
if (trouvoupas == 'N') if (trouvoupas == 'N')
{ {
printf("Le sport n'existe pas\n"); printf("Le sport n'existe pas\n");
return -1; return -1;
} }
if (tPO[position] < nbPtSpo[position]) prix = nbPtSpo[position];
if (tA[position] <= 25) //réduction si le client à - de 25ans
prix = prix * (85/100);
if (tA[position] >= 65) //réduction si le client à + de 65ans
prix = prix * (90/100);
if (tPO[position] < prix)
{ {
printf("Erreur, le client n'as pas assez de points\n"); printf("Erreur, le client n'as pas assez de points\n");
return -1; return -1;
} }
tPO[position] = tPO[position] - nbPtSpo [positionSpo]; tPO[position] = prix;
printf("Veut-il faire une autre activité ?\n"); printf("Veut-il faire une autre activité ?\n");
scanf("%c%*c",&nvAct); scanf("%c%*c",&nvAct);
} }
@ -135,7 +188,6 @@ int clientVenu (int *tNC, int *tCA, int *tPO, int *idSports, int *nbPtSpo, char
} }
} }
void affichageA(int *tNC, char *tN, char *tPR,int *tA, int *tCA,int *tPO, int n) void affichageA(int *tNC, char *tN, char *tPR,int *tA, int *tCA,int *tPO, int n)
{ {
int i ; int i ;
@ -148,20 +200,18 @@ void affichageA(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int n)
printf("----------------------------------------------------------------------------\n"); printf("----------------------------------------------------------------------------\n");
} }
/*int recherche(int*tNC,int n, int val, int* trouve) int rechercheclient(int *tNC,int n, int val, int* trouve)
{ {
int i; int i;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
{ {
if (tNC[i]==val) if (tNC[i]==val)
{ {
printf("le valeur %d est trouvé, sa position est %d\n",val,i);
*trouve = 1; *trouve = 1;
return i; return i;
} }
if(val<tNC[i]) if(val<tNC[i])
{ {
printf("le valeur %d n'est pas trouvé, son position d'insertion est %d\n",val,i);
*trouve = 0; *trouve = 0;
return i; return i;
} }
@ -172,31 +222,135 @@ void affichageA(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int n)
return i; return i;
} }
int insertpers(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO,int *nAdherent)
{
int i, val, age, trouve, place;
char nom, prenom;
val = tNC[*nAdherent-1]+1;
i=rechercheclient(tNC,*nAdherent,val,&trouve);
if(trouve == 0)
{
*nAdherent = *nAdherent+1;
place = i;
printf("%d",*nAdherent);
if(*nAdherent ==TAILLE)
{
printf("table pleinne");
return -1;
}
tNC[place]= val;
printf("donnez la premiere lettre de votre nom");
scanf("%c%*c",&nom);
tN[place]= nom;
printf("donnez la premiere lettre de votre prenom");
scanf("%c%*c",&prenom);
tPR[place] = prenom;
printf("donnez votre age");
scanf("%d%*c",&age);
tA[place]= age;
tCA[place]= 1;
tPO[place]= 0;
}
}
int supprpers(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO,int *nAdherent)
{
int i, val, trouve=0;
printf ("veillez indiquez le numéro de l'adhérent si vous ne voulez pas tappez -1\n");
scanf("%d%*c",&val);
i=rechercheclient(tNC,*nAdherent,val,&trouve);
if (val == -1)
{
return -1;
}
while (trouve != 1)
{
printf ("Veuillez indiquez le numéro de l'adhérent\n");
scanf("%d%*c",&val);
i=rechercheclient(tNC,*nAdherent,val,&trouve);
if (val == -1)
{
return -1;
}
}
void globale() for (i; i < *nAdherent; i++)
{ {
int n,valtrouve,trouve,tmax=50; tNC[i] = tNC[i+1];
int tNC[50],tA[50],tCA[50],tPO[50]; tN[i] = tN[i+1];
char tN[50],tPR[50]; tPR[i] = tPR[i+1];
n=creeadherent(tNC,tN,tPR,tA,tCA,tPO,250); tA[i] = tA[i+1];
affichageA(tNC,tN,tPR,tA,tCA,tPO, n); tCA[i] = tCA[i+1];
valtrouve=recherche(tNC,n,100,&trouve); tPO[i] = tPO[i+1];
}*/ }
*nAdherent = *nAdherent - 1; //réduit la taille logique
return 1;
void sauvegardeSports (int *idSports, int *pt, int n) }
void sauvegardeaderents(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO,int nAdherent)
{
int i;
FILE *fe;
fe = fopen("adherent.txt","w");
for (i = 0; i < nAdherent; i++)
fprintf(fe,"%d\t %d\t %d\t %d\t %d\t %d\n",tNC[i],tN[i],tPR[i],tA[i],tCA[i],tPO[i]);
fclose(fe);
}
void rajouteDpoints(int *tNC,int *tPO,int *nAdherent)
{
int point, numclient, i, trouve;
float prix;
char rep;
printf("Numéro client ? -1 pour quitter");
scanf("%d",&numclient);
i=rechercheclient(tNC,*nAdherent,numclient,&trouve);
while (trouve != 1)
{
printf ("erreur veillez indiquez le numéro de l'adhérent -1 pour quitter\n");
scanf("%d%*c",&numclient);
i=rechercheclient(tNC,*nAdherent,numclient,&trouve);
if (numclient == -1)
{
return;
}
}
printf("Combien voulez-vous rajouter de points?\n");
scanf("%d%*c",&point);
prix = 0.5 * point;
printf("le prix est de %.1f vouz confirmez? (O/N) \n",prix);
scanf("%c%*c",&rep);
if (rep == 'O')
{
tPO[i] = tPO[i] + point;
printf("votre nombre de points est de %d \n",tPO[i]);
}
else
{
printf("action annulé retour au menu");
return;
}
}
void sauvegardeSports (int *idSports, int *pt, int n, char listeSports[][20])
{ {
int i; int i;
FILE *fw; FILE *fw;
fw = fopen("sport.txt","w"); fw = fopen("sport.txt","w");
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
fprintf(fw,"%d\t%d\n",idSports[i],pt[i]); fprintf(fw,"%d\t%d\t%s\n",idSports[i],pt[i],listeSports[i]);
fclose(fw); fclose(fw);
} }
int chargementSport (int *idSports, int *nbPtSpo, int tmax) int chargementSport (int *idSports, int *nbPtSpo, int tmax, char listeSports[][20])
{ {
int idSportTemp, ptTemp, i = 0; int idSportTemp, ptTemp, i = 0;
char sportact[20];
FILE *fr; FILE *fr;
fr = fopen("sport.txt","r"); fr = fopen("sport.txt","r");
if (fr == NULL) if (fr == NULL)
@ -205,7 +359,7 @@ int chargementSport (int *idSports, int *nbPtSpo, int tmax)
fclose(fr); fclose(fr);
return -1; return -1;
} }
fscanf(fr,"%d%d",&idSportTemp,&ptTemp); fscanf(fr,"%d%d%s",&idSportTemp,&ptTemp,sportact);
while (!feof(fr)) while (!feof(fr))
{ {
if (i == tmax) if (i == tmax)
@ -215,24 +369,28 @@ int chargementSport (int *idSports, int *nbPtSpo, int tmax)
} }
idSports[i] = idSportTemp; idSports[i] = idSportTemp;
nbPtSpo[i] = ptTemp; nbPtSpo[i] = ptTemp;
strcpy(listeSports[i],sportact);
i++; i++;
fscanf(fr,"%d%d",&idSportTemp,&ptTemp); fscanf(fr,"%d%d%s",&idSportTemp,&ptTemp,sportact);
} }
fclose(fr); fclose(fr);
return i; return i;
} }
void affichage (int *idSports, int *pt, int n) void affichage (int *idSports, int *pt, int n, char listeSports[][20])
{ {
int i; int i;
printf("Sport:\tPoints:\n"); printf("----------------------------------------------\n");
printf("Sports:\t\tId:\tPoints:\n");
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
printf("%d\t%d\n",idSports[i],pt[i]); printf("%s:\t\t%d\t%d\n",listeSports[i],idSports[i],pt[i]);
} }
printf("----------------------------------------------\n");
} }
int recherche (int *tablchoisi ,int tailletabl, int valacherch, char *trouvoupas)
int rechercheSport(int *tablchoisi ,int tailletabl, int valacherch, char *trouvoupas)
{ {
int i; int i;
for (i = 0; i<tailletabl; i++) for (i = 0; i<tailletabl; i++)
@ -250,10 +408,10 @@ int recherche (int *tablchoisi ,int tailletabl, int valacherch, char *trouvoupas
} }
} }
void ajoutSport (int *idSports, int *pt, int *n, int taillePhys) void ajoutSport (int *idSports, int *pt, int *n, int taillePhys, char listeSports[][20])
{ {
int nvSpo, nvNbPt, place, i; int nvSpo, nvNbPt, place, i;
char trouvoupas; char trouvoupas , nvNom[20];
if (*n == taillePhys) //vérifie qu'il y a encore de la place dans le tableau if (*n == taillePhys) //vérifie qu'il y a encore de la place dans le tableau
{ {
printf("Erreur: la table est pleine"); printf("Erreur: la table est pleine");
@ -263,7 +421,9 @@ void ajoutSport (int *idSports, int *pt, int *n, int taillePhys)
scanf("%d%*c",&nvSpo); scanf("%d%*c",&nvSpo);
printf("Nombre de points du nouveau sport: \n"); printf("Nombre de points du nouveau sport: \n");
scanf("%d%*c",&nvNbPt); scanf("%d%*c",&nvNbPt);
place = recherche(idSports,*n,nvSpo,&trouvoupas); //donne où il doit ajouter le sport ou si il existe pas déjà printf("Nom du nouveau sport");
scanf("%s",nvNom);
place = rechercheSport(idSports,*n,nvSpo,&trouvoupas); //donne où il doit ajouter le sport ou si il existe pas déjà
if (trouvoupas == 'O') //si le sport existe déjà if (trouvoupas == 'O') //si le sport existe déjà
{ {
printf("Erreur, le sport existe déjà\n"); printf("Erreur, le sport existe déjà\n");
@ -273,9 +433,11 @@ void ajoutSport (int *idSports, int *pt, int *n, int taillePhys)
{ {
idSports[i+1] = idSports[i]; idSports[i+1] = idSports[i];
pt[i+1] = pt[i]; pt[i+1] = pt[i];
strcpy(listeSports[i+1],listeSports[i]);
} }
idSports[place] = nvSpo; //ajoute le sport a sa place idSports[place] = nvSpo; //ajoute le sport a sa place
pt[place] = nvNbPt; //ajoute le nb de points a sa place pt[place] = nvNbPt; //ajoute le nb de points a sa place
strcpy(listeSports[place],nvNom);
*n = *n + 1; //augmente la taille logique *n = *n + 1; //augmente la taille logique
return; return;
} }
@ -286,7 +448,7 @@ void changprix (int *idSport, int *pt, int n)
char trouve; char trouve;
printf("Changer le prix de quel sport ?\n"); printf("Changer le prix de quel sport ?\n");
scanf("%d%*c",&SpoChoix); scanf("%d%*c",&SpoChoix);
place = recherche(idSport,n,SpoChoix,&trouve); place = rechercheSport(idSport,n,SpoChoix,&trouve);
if (trouve == 'N') if (trouve == 'N')
{ {
printf("Erreur, le sport n'existe pas\n"); printf("Erreur, le sport n'existe pas\n");
@ -297,13 +459,13 @@ void changprix (int *idSport, int *pt, int n)
pt[place] = nvPrix ; pt[place] = nvPrix ;
} }
void enlèveSport (int *idSport, int *pt, int *n) void enlèveSport (int *idSport, int *pt, int *n, char listeSports[][20])
{ {
int place, i, supSpo; int place, i, supSpo;
char trouvoupas; char trouvoupas;
printf("Numéro du sport à supprimer: \n"); printf("Numéro du sport à supprimer: \n");
scanf("%d%*c",&supSpo); scanf("%d%*c",&supSpo);
place = recherche(idSport,*n,supSpo,&trouvoupas); //donne la place du sport et si il l'a trouvé place = rechercheSport(idSport,*n,supSpo,&trouvoupas); //donne la place du sport et si il l'a trouvé
if (trouvoupas == 'N') //il ne l'a pas trouvé if (trouvoupas == 'N') //il ne l'a pas trouvé
{ {
printf("Erreur, le sport existe pas\n"); printf("Erreur, le sport existe pas\n");
@ -313,6 +475,7 @@ void enlèveSport (int *idSport, int *pt, int *n)
{ {
idSport[i] = idSport[i+1]; idSport[i] = idSport[i+1];
pt[i] = pt[i+1]; pt[i] = pt[i+1];
strcpy(listeSports[i],listeSports[i+1]);
} }
*n = *n - 1; //réduit la taille logique *n = *n - 1; //réduit la taille logique
return; return;

@ -9,25 +9,42 @@
/* /*
\brief: gestion adhèrent \brief: gestion adhèrent
*/ */
int chargementadherent(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int Tmax);
int chargementadherent(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO);
/* /*
\brief: affiche les adèrent \brief: affiche les adèrent
*/ */
void affichageA(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int n); void affichageA(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int n);
/* /*
\brief: fonction qui recher le client \brief: fonction qui recher le client
*/ */
int recherche (int *tablchoisi ,int tailletabl, int valacherch, char *trouvoupas); //j'ai remplacé par la mienne car nom de variables plus générales , pour y utiliser dans plusieurs fonctions et que ça reste clair (j'ai mit la tienne en commentaire au cas où)
//tu fera gaffe pour savoir si il a trouvé j'utilise des char (O ou N) et pas des int int rechercheclient(int*tNC,int n, int val, int* trouve);
/* /*
\brief: ajoute un adèrent \brief: ajoute un adèrent
*/ */
int insertpers(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int Tmax);
int insertpers(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO,int *nAdherent);
/*
\brief: suprime un adèrent
*/
int supprpers(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO,int *nAdherent);
/*
\brief: sauvegarde le tableau dans le fichier adèrent
*/
void rajouteDpoints(int *tNC,int *tPO,int *nAdherent);
/*
\brief: rajoute des points
*/
void sauvegardeaderents(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO,int nAdherent);
/* /*
\brief: globale \brief: globale
@ -37,19 +54,19 @@ void globale(); //pareil , mit en com et remplacé par mon tableau (où j'ai raj
/* /*
brief: charge les sports brief: charge les sports
*/ */
int chargementSport (int *idSports, int *nbPtSpo, int tmax); int chargementSport (int *idSports, int *nbPtSpo, int tmax, char listeSports[][20]);
/* /*
brief: affiche les sports brief: affiche les sports
*/ */
void affichage (int *idSports, int *pt, int n); void affichage (int *idSports, int *pt, int n, char listeSports[][20]);
/* /*
brief: enlève un sport brief: enlève un sport
*/ */
void enlèveSport (int *idSport, int *pt, int *n); void enlèveSport (int *idSport, int *pt, int *n, char listeSports[][20]);
/* /*
brief: menu brief: menu
@ -63,12 +80,42 @@ void chargementInit (void);
int rechercheSport (int *tablchoisi ,int tailletabl, int valacherch, char *trouvoupas); int rechercheSport (int *tablchoisi ,int tailletabl, int valacherch, char *trouvoupas);
void sauvegardeSports (int *idSports, int *pt, int n); /*
brief: sauvegarde les sports ds le fichier
*/
void sauvegardeSports (int *idSports, int *pt, int n, char listeSports[][20]);
/*
brief: Ajoute un sport
*/
void ajoutSport (int *idSports, int *pt, int *n, int taillePhys); void ajoutSport (int *idSports, int *pt, int *n, int taillePhys, char listeSports[][20]);
/*
brief: change le prix d'un sport
*/
void changprix (int *idSport, int *pt, int n); void changprix (int *idSport, int *pt, int n);
int clientVenu (int *tNC, int *tCA, int *tPO, int *idSports, int *nbPtSpo, char *venu); /*
brief: ce que fait le client
*/
int clientVenu (int *tNC, int *tCA, int *tPO, int *tA, int *idSports, int *nbPtSpo, char *venu);
/*
brief: Choix pr les activités
*/
int choixMenuAct (int choix, int *idSports, int *nbPtSpo, int *nSports, int *tNC, int *tA, int *tCA, int *tPO, int *nAdherent, char *tN, char *tPR, char *venu, char listeSports[][20]);
/*
brief: choix du menu
*/
int menuChoix (int choix, int *idSports, int *nbPtSpo, int *nSports, int *tNC, int *tA, int *tCA, int *tPO, int *nAdherent, char *tN, char *tPR, char *venu, char listeSports[][20]);
/*
brief: Choix pr les adhérents
*/
int choixMenu (int choix, int *idSports, int *nbPtSpo, int *nSports, int *tNC, int *tA, int *tCA, int *tPO, int *nAdherent, char *tN, char *tPR, char *venu); int choixMenuAd (int choix, int *idSports, int *nbPtSpo, int *nSports, int *tNC, int *tA, int *tCA, int *tPO, int *nAdherent, char *tN, char *tPR, char *venu, char listeSports[][20]);

@ -1,4 +1,12 @@
1 6 1 10 Aquagy
3 5 2 6 Natati
5 18 3 8 Waterp
7 56 4 10 Muscu
5 15 Foot
6 15 Basket
7 8 Badmin
8 11 Tennis
9 4 PingPo
10 15 Spa
11 30 Massag
12 17 Relax

Loading…
Cancel
Save