From dbc488082ea4a228cda9603a1564ba70fd2af6a3 Mon Sep 17 00:00:00 2001 From: Renaud BEURET Date: Thu, 3 Nov 2022 13:22:45 +0100 Subject: [PATCH] =?UTF-8?q?Modification=20du=20fonctionnement=20du=20menu?= =?UTF-8?q?=20pour=20que=20le=20logiciel=20ne=20s'arr=C3=AAte=20pas=20apr?= =?UTF-8?q?=C3=A8s=20avoir=20fini=20une=20option=20,=20et=20ajout=20de=20l?= =?UTF-8?q?'option=20"arriv=C3=A9e=20d'un=20client"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- saeN.c | 142 ++++++++++++++++++++++++++++++++++++----------------- saeN.h | 10 ++-- saetestN.c | 2 +- 3 files changed, 106 insertions(+), 48 deletions(-) diff --git a/saeN.c b/saeN.c index 7aa76b7..6aa4b83 100644 --- a/saeN.c +++ b/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