diff --git a/adherent.txt b/adherent.txt index f255129..8ee5c5c 100644 --- a/adherent.txt +++ b/adherent.txt @@ -1,2 +1,3 @@ -100 P J 52 1 42 -101 D F 18 0 51 +100 56 55 52 1 42 +102 55 55 25 1 117 +103 55 56 30 1 3 diff --git a/saeN.c b/saeN.c index 6aa4b83..600ba4e 100644 --- a/saeN.c +++ b/saeN.c @@ -5,17 +5,40 @@ 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 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; + char tN[50],tPR[50],venu[50] = {0}, listeSports[50][20]; + nSports = chargementSport(idSports,nbPtSpo,TAILLE,listeSports); + nAdherent = chargementadherent(tNC,tN,tPR,tA,tCA,tPO); + printf("\nBienvenue , veuillez choisir le type d'action que vous voulez faire \n"); + 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("| 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("| 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("| |\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");affichage(idSports,nbPtSpo,*nSports); printf("\n");} + {printf("\n");affichage(idSports,nbPtSpo,*nSports,listeSports); printf("\n");} 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) - {printf("\n");enlèveSport(idSports,nbPtSpo,nSports);printf("\n");} + {printf("\n");enlèveSport(idSports,nbPtSpo,nSports,listeSports);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); + menuChoix (choix,idSports,nbPtSpo,nSports,tNC,tA,tCA,tPO,nAdherent,tN,tPR,venu,listeSports); + sauvegardeSports(idSports,nbPtSpo,*nSports,listeSports); 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; 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); while (!feof(fe)) { - if(i==Tmax) + if(i==TAILLE) { - printf("%d \t %d\n",i, Tmax); - printf("capasité atteinte\n"); + printf("%d \t %d\n",i, TAILLE); + printf("capacité atteinte\n"); fclose(fe); return -1; } @@ -84,30 +130,32 @@ int chargementadherent(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, in tPO[i]=PO; i++; fscanf(fe,"%d %s %s %d %d %d",&NC,&N,&PR,&A,&CA,&PO); + } fclose(fe); 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'; printf("Quel client est arrivé ?\n"); 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') { - printf("Erreur, le client est déjà venu aujourd'hui"); + printf("Erreur, le client est déjà venu aujourd'hui\n"); 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 + printf("Erreur, le client n'existe pas\n"); return 0; } if (trouvoupas == 'O') @@ -116,29 +164,33 @@ int clientVenu (int *tNC, int *tCA, int *tPO, int *idSports, int *nbPtSpo, char { printf("Quelle activité va t-il faire ?\n"); scanf("%d%*c",&activité); - positionSpo = recherche(idSports,TAILLE,activité,&trouvoupas); + positionSpo = rechercheSport(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); + 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"); + return -1; + } + tPO[position] = prix; + 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) +void affichageA(int *tNC, char *tN, char *tPR,int *tA, int *tCA,int *tPO, int n) { - int i; + int i ; printf("----------------------------------------------------------------------------\n"); printf("n°client nom\t prenom\t age\t carte\t point\n"); for (i=0;i