From 8ecbc3bf6bcdfc4fa853aa54c41f42d9a629b724 Mon Sep 17 00:00:00 2001 From: IA Date: Wed, 9 Nov 2022 21:02:39 +0100 Subject: [PATCH] ajout de la fonction menu et patch de la fonction ouverture --- ActivitesJour.don | 20 +++--- SAE.c | 171 +++++++++++++++++++++++++++++++++------------- SAE.h | 6 +- exe | Bin 17048 -> 17016 bytes membres.don | 19 +++--- testSAE.c | 24 ++++--- 6 files changed, 161 insertions(+), 79 deletions(-) diff --git a/ActivitesJour.don b/ActivitesJour.don index af64d63..fdd8e5c 100644 --- a/ActivitesJour.don +++ b/ActivitesJour.don @@ -1,10 +1,10 @@ - Date nbActivitesJour -12082022 500 -5092022 525 -7092022 740 -8092022 812 -9092022 850 -10092022 620 -11092022 601 -12092022 422 -13092022 501 +01 500 +02 550 +03 600 +04 520 +05 500 +06 515 +07 500 +08 612 +09 705 +10 800 diff --git a/SAE.c b/SAE.c index 03ce7b2..c4d3292 100644 --- a/SAE.c +++ b/SAE.c @@ -1,25 +1,26 @@ #include "SAE.h" -int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int tmax) +int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int tmax, int *pasAct) { - int i = 0, j = 0; + int pasMembres, pasAct; + pasMembres = OuvertureMembres(tNoCarte, tage, tPointsCarte, tCarteActive, tmax); + pasAct = OuvertureActivitesJour(tNbActivitesJour, tDate, tmax); + *pasAct = pasAct; + return pasMembres +} + +int OuvertureMembres(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tmax) +{ + int i = 0; int NoCarte, age, pointsCarte, CarteActive; - int Date, nbActivitesJour; - FILE *flot, *jour; + FILE *flot; flot = fopen("membres.don", "r"); - jour = fopen("ActivitesJour.don", "r"); if(flot == NULL) { printf("Pb d'ouverture du fichier membres.don\n"); return -1; } - if(jour == NULL) - { - printf("Pb d'ouverture du fichier ActivitesJour.don\n"); - return -1; - } - fscanf(flot, "%d%d%d%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive); - fscanf(jour, "%d%d", &Date, &nbActivitesJour); + fscanf(flot, "%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive); while(!feof(flot)) { if(i == tmax) @@ -32,27 +33,131 @@ int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[] tage[i] = age; tPointsCarte[i] = pointsCarte; tCarteActive[i] = CarteActive; - fscanf(flot, "%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive); + fscanf(flot, "%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive); i++; } + fclose(flot); + return i; +} +int OuvertureActivitesJour(int tNbActivitesJour[], int tDate[], int tmax) +{ + int i = 0; + int Date, nbActivitesJour; + FILE *jour; + jour = fopen("ActivitesJour.don", "r"); + if(jour == NULL) + { + printf("Pb d'ouverture du fichier ActivitesJour.don\n"); + return -1; + } + fscanf(jour, "%d%d", &Date, &nbActivitesJour); while(!feof(jour)) { - if(j == tmax) + if(i == tmax) { printf("Tableau plein\n"); fclose(jour); return -1; } - tDate[j] = Date; - tNbActivitesJour[j] = nbActivitesJour; + tDate[i] = Date; + tNbActivitesJour[i] = nbActivitesJour; fscanf(jour, "%d%d", &Date, &nbActivitesJour); - j++; + i++; } fclose(jour); - fclose(flot); return i; } +int choixMenu(void) +{ + int choix; + printf("\t Gestion des matières\n"); + printf("1.\taffichage\n"); + printf("2.\tAjouter un client\n"); + printf("3.\tModifier l'âge d'un client\n"); + printf("4.\tsuppression d'un client\n"); + printf("5.\tAjout de points sur une carte\n"); + printf("6.\tModification de l'état de la carte\n"); + printf("7.\tCréditer une activité à une carte\n"); + printf("8.\tquitter\n"); + printf("\noption choisie :\n"); + scanf("%d", &choix); + return choix; +} + +void gestionMatieres(void) +{ + int tNoCarte[20] = {0}, tage[20] = {0}, tPointsCarte[20] = {0}, tCarteActive[20] = {0}; + int tDate[20] = {0}, tNbActivitesJour[20] = {0}; + int tmax = 20, nbelem, choix, pasAct; + nbelem = Ouverture(tNoCarte, tage, tPointsCarte, tCarteActive, tNbActivitesJour, tDate, tmax, &pasAct); + if(nbMatieres < 0) + { + printf("Erreur d'ouverture du fichier ou tableau plein !!!\n"); + return ; + } + choix = choixMenu(); + while(choix != 9) + { + if(choix == 1) + { + affichage(tMatieres, tCoeff, nbMatieres); + } + if(choix == 2) + { + modificationCoefficient(tMatieres, tCoeff, nbMatieres); + } + if(choix == 3) + { + nbMatieres = insertionNewMatiere(tMatieres, tCoeff, nbMatieres, max); + } + if(choix == 4) + { + nbMatieres = suppressionMatiere(tMatieres, tCoeff, nbMatieres); + } + if(choix == 5) + { + MoyenneNotesMatiere(tMatieres, tNotes, tNbNotes, nbMatieres); + } + if(choix == 6) + { + MoyenneEtudiant(tCoeff, tMatieres, tNotes, tNbNotes, nbMatieres); + } + choix = choixMenu(); + } + sauvegarde(tMatieres, tCoeff, nbMatieres); + fclose(flot); + exit(1); +} +/* +int Sauvegarde(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int nbelem) +{ + int i, j; + FILE *flot, *jour; + flot = fopen("membres.don", "a"); + jour = fopen("ActivitesJour.don", "a"); + if(flot == NULL) + { + printf("Pb d'ouverture du fichier membres.don\n"); + return -1; + } + if(jour == NULL) + { + printf("Pb d'ouverture du fichier ActivitesJour.don\n"); + return -1; + } + for(i = 0; i < (nbelem-1); i++) + { + fprintf(flot, "\t%d\t%d\t\t%d\t\t%d\n", tNoCarte[i], tage[i], tPointsCarte[i], tCarteActive[i]); + } + for(j = 0; j < (nbelem-1); j++) + { + fprintf(jour, "%d\t\t%d\n", tDate[j], tNbActivitesJour[j]); + } + fclose(jour); + fclose(flot); +} + void ajouterPoints(int tNumCarte[], int tPoints[], int tailleLog) { @@ -118,36 +223,10 @@ int recherche(int tab[], int tailleLog, int valeur, int *trouve) return tailleLog; } -/* -int Sauvegarde(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int nbelem) -{ - int i, j; - FILE *flot, *jour; - flot = fopen("membres.don", "a"); - jour = fopen("ActivitesJour.don", "a"); - if(flot == NULL) - { - printf("Pb d'ouverture du fichier membres.don\n"); - return -1; - } - if(jour == NULL) - { - printf("Pb d'ouverture du fichier ActivitesJour.don\n"); - return -1; - } - for(i = 0; i < (nbelem-1); i++) - { - fprintf(flot, "\t%d\t%d\t\t%d\t\t%d\n", tNoCarte[i], tage[i], tPointsCarte[i], tCarteActive[i]); - } - for(j = 0; j < (nbelem-1); j++) - { - fprintf(jour, "%d\t\t%d\n", tDate[j], tNbActivitesJour[j]); - } - fclose(jour); - fclose(flot); -} + + int ajoutPointsCarte(int tNoCarte[], int tPointsCarte[], int tCarteActive[], int nbelem) { diff --git a/SAE.h b/SAE.h index 76bb56a..70ded68 100644 --- a/SAE.h +++ b/SAE.h @@ -1,11 +1,13 @@ #include #include -int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int tmax); +int OuvertureMembres(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tmax); +int OuvertureActivitesJour(int tNbActivitesJour[], int tDate[], int tmax); void testOuverture(void); +/* int Sauvegarde(); void testSauvegarde(void); -/* + int pointsBonus(); int CreationAdherent(); int FrequenceCentre(); diff --git a/exe b/exe index 5d118ea19c6fe8f4e242c1baef76390bf552a187..2e56178690e22cb21a676c249274dfa185731b5b 100755 GIT binary patch delta 3607 zcmaJ^eQXow8Gr8_J9hYp?UFd5u-KsmvJE>nNrM5$Hi_Fe42DyZ5+*f?3C`jz6EcltJbVylBwFs5wvp|R1ON+b2`ORdM$(>*lWyYi)35Q1nl-qv#n{Vlo8c|H1{=2Q{L7^x-C?rP4 zT9jr*G0l?Qj8!)vi6dm3`KiTh5si;yi>O8|q>BCRnt4m;@QFWtUfR>C?RET4d;MpB zcBx2)eX3*yxH0e*%a02|D~L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