diff --git a/sequegfait/adherent.txt b/sequegfait/adherent.txt new file mode 100644 index 0000000..8ee5c5c --- /dev/null +++ b/sequegfait/adherent.txt @@ -0,0 +1,3 @@ +100 56 55 52 1 42 +102 55 55 25 1 117 +103 55 56 30 1 3 diff --git a/sequegfait/saeN.c b/sequegfait/saeN.c new file mode 100644 index 0000000..ef2e6bc --- /dev/null +++ b/sequegfait/saeN.c @@ -0,0 +1,432 @@ +#include +#include +#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é TAILLE 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); + nAdherent = chargementadherent(tNC,tN,tPR,tA,tCA,tPO); + 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. suppre personne |\n"); + printf("| 2. Ajout de points |\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");supprpers(tNC,tN,tPR,tA,tCA,tPO,nAdherent); printf("\n");} + if (choix == 2) + {printf("\n");rajouteDpoints(tNC,tPO,nAdherent);; 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");insertpers(tNC,tN,tPR,tA,tCA,tPO,nAdherent);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); + sauvegardeaderents(tNC,tN,tPR,tA,tCA,tPO,*nAdherent); + sauvegardeSports(idSports,nbPtSpo,*nSports); + 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; + fe=fopen("adherent.txt","r"); + if(fe == NULL) + { + printf("pbouvrfichier\n"); + return -1; + } + + fscanf(fe,"%d %s %s %d %d %d",&NC,&N,&PR,&A,&CA,&PO); + while (!feof(fe)) + { + if(i==TAILLE) + { + printf("%d \t %d\n",i, TAILLE); + printf("capasité atteinte\n"); + fclose(fe); + return -1; + } + tNC[i]=NC; + tN[i]=N; + tPR[i]=PR; + tA[i]=A; + tCA[i]=CA; + 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 arrive, position, positionSpo, activité; + char trouvoupas, creation, nvAct = 'O'; + printf("Quel client est arrivé ?\n"); + scanf("%d%*c",&arrive); + position = rechercheSport(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 = 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); + } + venu[position] = 'O'; + } +} + + +void affichageA(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int n) +{ + printf("%d\n",tA[3]); + int i; + printf("----------------------------------------------------------------------------\n"); + printf("n°client nom\t prenom\t age\t carte\t point\n"); + for (i=0;i valacherch) //il est plus loin que la valeur a recherché donc a pas trouvé + { + *trouvoupas = 'N'; + return i; + } + } +} + +void ajoutSport (int *idSports, int *pt, int *n) +{ + int nvSpo, nvNbPt, place, i; + char trouvoupas; + if (*n == TAILLE) //vérifie qu'il y a encore de la place dans le tableau + { + printf("Erreur: la table est pleine"); + return; + } + printf("Numéro du nouveau sport: \n"); + 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à + if (trouvoupas == 'O') //si le sport existe déjà + { + printf("Erreur, le sport existe déjà\n"); + return; + } + for (i = *n - 1 ; i >= place; i--) //décale les sports après celui à ajouter + { + idSports[i+1] = idSports[i]; + pt[i+1] = pt[i]; + } + idSports[place] = nvSpo; //ajoute le sport a sa place + pt[place] = nvNbPt; //ajoute le nb de points a sa place + *n = *n + 1; //augmente la taille logique + return; +} + +void changprix (int *idSport, int *pt, int n) +{ + int nvPrix , SpoChoix, place; + char trouve; + printf("Changer le prix de quel sport ?\n"); + scanf("%d%*c",&SpoChoix); + place = rechercheSport(idSport,n,SpoChoix,&trouve); + if (trouve == 'N') + { + printf("Erreur, le sport n'existe pas\n"); + return; + } + printf("Veuillez rentrer le nouveau prix: \n"); + scanf("%d%*c",&nvPrix); + pt[place] = nvPrix ; +} + +void enlèveSport (int *idSport, int *pt, int *n) +{ + int place, i, supSpo; + 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é + if (trouvoupas == 'N') //il ne l'a pas trouvé + { + printf("Erreur, le sport existe pas\n"); + return; + } + for (i = place ; i < *n - 1; i++) //décalle pour pouvoir supprimer le sport + { + idSport[i] = idSport[i+1]; + pt[i] = pt[i+1]; + } + *n = *n - 1; //réduit la taille logique + return; +} diff --git a/sequegfait/saeN.h b/sequegfait/saeN.h new file mode 100644 index 0000000..43bb04e --- /dev/null +++ b/sequegfait/saeN.h @@ -0,0 +1,86 @@ +/* \file: sae.h + \author: Nolan Devouassoux, Renaud Beuret + \date: 25 oct + + */ + + + + /* + \brief: gestion adhèrent + */ +int chargementadherent(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO); + + /* + \brief: affiche les adèrent + */ +void affichageA(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int n); + + /* + \brief: fonction qui recher le client + */ +int rechercheclient(int*tNC,int n, int val, int* trouve); + /* + \brief: ajoute un adèrent + */ +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 + */ +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); + +/* + 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 chargementInit (void); + +/* + brief: recherche sport +*/ + +int rechercheSport (int *tablchoisi ,int tailletabl, int valacherch, char *trouvoupas); + +void sauvegardeSports (int *idSports, int *pt, int n); + +void ajoutSport (int *idSports, 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); + +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); \ No newline at end of file diff --git a/sequegfait/saetestN.c b/sequegfait/saetestN.c new file mode 100644 index 0000000..52bc20a --- /dev/null +++ b/sequegfait/saetestN.c @@ -0,0 +1,8 @@ +#include "saeN.h" +#include + +int main(void) +{ + chargementInit(); + return 0; +} diff --git a/sequegfait/sport.txt b/sequegfait/sport.txt new file mode 100644 index 0000000..5178ae4 --- /dev/null +++ b/sequegfait/sport.txt @@ -0,0 +1,4 @@ +1 6 +3 5 +5 18 +7 56 diff --git a/sequegfait/test b/sequegfait/test new file mode 100755 index 0000000..9a2c827 Binary files /dev/null and b/sequegfait/test differ