Modification du fonctionnement du menu pour que le logiciel ne s'arrête pas après avoir fini une option , et ajout de l'option "arrivée d'un client"

master
Renaud BEURET 3 years ago
parent 1b3c3e27b9
commit dbc488082e

142
saeN.c

@ -3,6 +3,58 @@
#include "saeN.h"
#define TAILLE 50
void chargementInit (void)
{
int idSports[TAILLE], nbPtSpo[TAILLE], nSports, choix/*nb de sports, choix*/;
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
char tN[50],tPR[50],venu[50] = {0};
nSports = chargementSport(idSports,nbPtSpo,TAILLE);
nAdherent = chargementadherent(tNC,tN,tPR,tA,tCA,tPO,TAILLE);
choixMenu(choix,idSports,nbPtSpo,&nSports,tNC,tA,tCA,tPO,&nAdherent,tN,tPR,venu);
return;
}
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)
{
printf("------------------------------------------------\n"); //tableau qui s'affiche en premier pour choisir
printf("| Gestion des activités |\n");
printf("| |\n");
printf("| 1. Affichage des Activités |\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("| 5. Afficher les adhérents |\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("| |\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,*nSports); printf("\n");}
if (choix == 2)
{printf("\n");ajoutSport(idSports,nbPtSpo,nSports,TAILLE); printf("\n");}
if (choix == 3)
{printf("\n");enlèveSport(idSports,nbPtSpo,nSports);printf("\n");}
if (choix == 4)
{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
{printf("\n"); printf("Arrêt du logiciel"); printf("\n"); printf("\n");}
if (choix != 9)
choixMenu (choix,idSports,nbPtSpo,nSports,tNC,tA,tCA,tPO,nAdherent,tN,tPR,venu);
sauvegardeSports(idSports,nbPtSpo,*nSports);
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 NC,N,PR,A,CA,PO, i=0;
@ -37,7 +89,51 @@ int chargementadherent(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, in
return i;
}
int clientVenu (int *tNC, int *tCA, int *tPO, int *idSports, int *nbPtSpo, char *venu)
{
int arrive, position, positionSpo, activité;
char trouvoupas, creation, nvAct = 'O';
printf("Quel client est arrivé ?\n");
scanf("%d%*c",&arrive);
position = recherche(tNC,TAILLE,arrive,&trouvoupas);
if (venu[position] == 'O')
{
printf("Erreur, le client est déjà venu aujourd'hui");
return -1;
}
if (trouvoupas == 'N')
{
printf("Erreur, le client n'existe pas, voulez vous le créer ?\n");
scanf("%c%*c",&creation);
if (creation == 'O')
{/*Mettre la fonction ajouter un adhérent*/ return 0;}
else
return 0;
}
if (trouvoupas == 'O')
{
while (nvAct == 'O')
{
printf("Quelle activité va t-il faire ?\n");
scanf("%d%*c",&activité);
positionSpo = recherche(idSports,TAILLE,activité,&trouvoupas);
if (trouvoupas == 'N')
{
printf("Le sport n'existe pas\n");
return -1;
}
if (tPO[position] < nbPtSpo[position])
{
printf("Erreur, le client n'as pas assez de points\n");
return -1;
}
tPO[position] = tPO[position] - nbPtSpo [positionSpo];
printf("Veut-il faire une autre activité ?\n");
scanf("%c%*c",&nvAct);
}
venu[position] = 'O';
}
}
void affichageA(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int n)
@ -88,48 +184,6 @@ void globale()
valtrouve=recherche(tNC,n,100,&trouve);
}*/
void gestionAvecMenu (void)
{
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("| 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"); //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,nSports); printf("\n");}
if (choix == 2)
{printf("\n");ajoutSport(idSports,nbPtSpo,&nSports,TAILLE); printf("\n");}
if (choix == 3)
{printf("\n");enlèveSport(idSports,nbPtSpo,&nSports);printf("\n");}
if (choix == 4)
{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,nSports);
return;
}
void sauvegardeSports (int *idSports, int *pt, int n)
{
int i;
@ -181,7 +235,7 @@ void affichage (int *idSports, int *pt, int n)
int recherche (int *tablchoisi ,int tailletabl, int valacherch, char *trouvoupas)
{
int i;
for (i=1; i<tailletabl; i++)
for (i = 0; i<tailletabl; i++)
{
if (tablchoisi[i] == valacherch) //il a trouvé
{

@ -19,8 +19,8 @@ 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); //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ù)
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
/*
\brief: ajoute un adèrent
@ -55,7 +55,7 @@ void enlèveSport (int *idSport, int *pt, int *n);
brief: menu
*/
void gestionAvecMenu (void);
void chargementInit (void);
/*
brief: recherche sport
@ -68,3 +68,7 @@ void sauvegardeSports (int *idSports, int *pt, int n);
void ajoutSport (int *idSports, int *pt, int *n, int taillePhys);
void changprix (int *idSport, int *pt, int n);
int clientVenu (int *tNC, int *tCA, int *tPO, int *idSports, int *nbPtSpo, char *venu);
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);

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

Loading…
Cancel
Save