Implémentation du menu et quelques autres légrère modifications

master
Shrayzz 3 years ago
parent f606fb46f3
commit 1b3c3e27b9

@ -3,7 +3,7 @@
#include "saeN.h"
#define TAILLE 50
int creeadherent(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, int Tmax) //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;
FILE *fe;
@ -52,7 +52,7 @@ void affichageA(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int n)
printf("----------------------------------------------------------------------------\n");
}
int recherche(int*tNC,int n, int val, int* trouve)
/*int recherche(int*tNC,int n, int val, int* trouve)
{
int i;
for(i=0;i<n;i++)
@ -86,35 +86,47 @@ void globale()
n=creeadherent(tNC,tN,tPR,tA,tCA,tPO,250);
affichageA(tNC,tN,tPR,tA,tCA,tPO, n);
valtrouve=recherche(tNC,n,100,&trouve);
}
}*/
void gestionAvecMenu (void)
{
int idSports[TAILLE], nbPtSpo[TAILLE], n, choix;
n = chargementSport(idSports,nbPtSpo,TAILLE);
int idSports[TAILLE], nbPtSpo[TAILLE], nSports /*nb de sports, choix;
int tNC[50], tA[50], tCA[50], tPO[50]; //pour tes fonctions
int nAdherent /*nb d'adherents*/,valtrouve,trouve; //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];
nSports = chargementSport(idSports,nbPtSpo,TAILLE);
nAdherent = chargementadherent(tNC,tN,tPR,tA,tCA,tPO,TAILLE);
printf("------------------------------------------------\n"); //tableau qui s'affiche en premier pour choisir
printf("| Gestion des activités |\n");
printf("| |\n");
printf("| 1. Affichage |\n");
printf("| 2. Ajout 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("| 6. Ajouter un adhérent |\n");
printf("| |\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("| |\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"),affichage(idSports,nbPtSpo,n); printf("\n");}
{printf("\n");affichage(idSports,nbPtSpo,nSports); printf("\n");}
if (choix == 2)
{printf("\n"),ajoutSport(idSports,nbPtSpo,&n,TAILLE); printf("\n");}
{printf("\n");ajoutSport(idSports,nbPtSpo,&nSports,TAILLE); printf("\n");}
if (choix == 3)
{printf("\n"),enlèveSport(idSports,nbPtSpo,&n);printf("\n");}
{printf("\n");enlèveSport(idSports,nbPtSpo,&nSports);printf("\n");}
if (choix == 4)
{printf("\n"),changprix(idSports,nbPtSpo,n);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 == 9) //quitte le logiciel si l'utilisateur a rentré 9
{printf("\n"); printf("Arrêt du logiciel"); printf("\n"); printf("\n");}
sauvegardeSports(idSports,nbPtSpo,n);
sauvegardeSports(idSports,nbPtSpo,nSports);
return;
}
@ -166,7 +178,7 @@ void affichage (int *idSports, int *pt, int n)
}
}
int rechercheSport (int *tablchoisi ,int tailletabl, int valacherch, char *trouvoupas)
int recherche (int *tablchoisi ,int tailletabl, int valacherch, char *trouvoupas)
{
int i;
for (i=1; i<tailletabl; i++)
@ -197,7 +209,7 @@ void ajoutSport (int *idSports, int *pt, int *n, int taillePhys)
scanf("%d%*c",&nvSpo);
printf("Nombre de points du nouveau sport: \n");
scanf("%d%*c",&nvNbPt);
place = rechercheSport(idSports,*n,nvSpo,&trouvoupas); //donne où il doit ajouter le sport ou si il existe pas déjà
place = recherche(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à
{
printf("Erreur, le sport existe déjà\n");
@ -220,7 +232,7 @@ void changprix (int *idSport, int *pt, int n)
char trouve;
printf("Changer le prix de quel sport ?\n");
scanf("%d%*c",&SpoChoix);
place = rechercheSport(idSport,n,SpoChoix,&trouve);
place = recherche(idSport,n,SpoChoix,&trouve);
if (trouve == 'N')
{
printf("Erreur, le sport n'existe pas\n");
@ -237,7 +249,7 @@ void enlèveSport (int *idSport, int *pt, int *n)
char trouvoupas;
printf("Numéro du sport à supprimer: \n");
scanf("%d%*c",&supSpo);
place = rechercheSport(idSport,*n,supSpo,&trouvoupas); //donne la place du sport et si il l'a trouvé
place = recherche(idSport,*n,supSpo,&trouvoupas); //donne la place du sport et si il l'a trouvé
if (trouvoupas == 'N') //il ne l'a pas trouvé
{
printf("Erreur, le sport existe pas\n");

@ -9,7 +9,7 @@
/*
\brief: gestion adhèrent
*/
int creeadherent(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, int Tmax);
/*
\brief: affiche les adèrent
@ -19,7 +19,7 @@ void affichageA(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int n);
/*
\brief: fonction qui recher le client
*/
int recherche(int*tNC,int n, int val, int*trouve);
int recherche(int*tNC,int n, int val, int*trouve); //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ù)
/*
@ -32,16 +32,35 @@ int recherche(int*tNC,int n, int val, int*trouve);
/*
\brief: globale
*/
void globale();
void globale(); //pareil , mit en com et remplacé par mon tableau (où j'ai rajouté tes fonctions)
/*
brief: charge les sports
*/
int chargementSport (int *idSports, int *nbPtSpo, int tmax);
/*
brief: affiche les sports
*/
void affichage (int *idSports, int *pt, int n);
/*
brief: enlève un sport
*/
void enlèveSport (int *idSport, int *pt, int *n);
/*
brief: menu
*/
void gestionAvecMenu (void);
/*
brief: recherche sport
*/
int rechercheSport (int *tablchoisi ,int tailletabl, int valacherch, char *trouvoupas);
void sauvegardeSports (int *idSports, int *pt, int n);

@ -3,6 +3,6 @@
int main(void)
{
globale();
gestionAvecMenu();
return 0;
}

Loading…
Cancel
Save