From b8d45f5926417396a9ac00217a1d2d2b9a5d2285 Mon Sep 17 00:00:00 2001 From: "antoine.perederii" Date: Thu, 10 Nov 2022 15:15:33 +0100 Subject: [PATCH] =?UTF-8?q?mise=20sous=20diff=C3=A9rents=20fichiers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ActivitesJour.don | 8 + Affichage.c | 59 ++++++ SAE.h => Fonctions.h | 2 +- GestionAdherents.c | 129 ++++++++++++ GestionPoints.c | 97 +++++++++ Global.c | 75 +++++++ Menus.c | 33 +++ Ouverture.c | 69 ++++++ SAE.c | 486 ------------------------------------------- Sauvegarde.c | 29 +++ exe | Bin 26072 -> 30400 bytes testSAE.c => main.c | 2 +- membres.don | 8 + 13 files changed, 509 insertions(+), 488 deletions(-) create mode 100644 Affichage.c rename SAE.h => Fonctions.h (94%) create mode 100644 GestionAdherents.c create mode 100644 GestionPoints.c create mode 100644 Global.c create mode 100644 Menus.c create mode 100644 Ouverture.c delete mode 100644 SAE.c create mode 100644 Sauvegarde.c rename testSAE.c => main.c (98%) diff --git a/ActivitesJour.don b/ActivitesJour.don index b9d8a67..e6eb2bd 100644 --- a/ActivitesJour.don +++ b/ActivitesJour.don @@ -7,3 +7,11 @@ 7 601 8 422 9 501 +1 500 +2 525 +3 740 +4 812 +5 850 +6 620 +7 601 +8 422 diff --git a/Affichage.c b/Affichage.c new file mode 100644 index 0000000..933f91e --- /dev/null +++ b/Affichage.c @@ -0,0 +1,59 @@ +#include "Fonctions.h" + +void Affichage1Adherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem) +{ + int pas, NoCarte, CarteActive, trouve; + printf("Entrez le numéro de la carte de l'adhérent recherché : "); + scanf("%d",&NoCarte); + pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); + if(trouve == 1) + { + printf(" N°_de_carte\tAge Points Carte_active\n"); + printf("\t%d\t%d\t%d\t%d\n", tNoCarte[pas], tage[pas], tPointsCarte[pas], tCarteActive[pas]); + } + else + { + printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); + return; + } +} + +void AffichageTousAdherents(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem) +{ + int i; + printf(" N°_de_carte\tAge Points Carte_active\n"); + for (i = 0; i < nbelem; i++) + { + printf("\t%d\t%d\t%d\t%d\n", tNoCarte[i], tage[i], tPointsCarte[i], tCarteActive[i]); + } +} + +void AffichageNbEntreesTousJour(int tNbActivitesJour[], int tDate[], int nbelem) +{ + int i; + printf(" Date\tNb_Activites\n"); + for (i = 0; i < nbelem; i++) + { + printf("\t%d\t%d\n", tDate[i], tNbActivitesJour[i]); + } +} + +void AffichageNbEntreesTotal(int tNbActivitesJour[], int nbelem) +{ + int i, somme = 0; + for (i = 0; i < nbelem; i++) + { + somme = somme + tNbActivitesJour[i]; + } + printf("Le nombre total d'entrées est de %d depuis le début.\n", somme); +} + +void AffichageNbAdherents(int nbelem) +{ + int i, somme = 0; + for (i = 0; i < nbelem; i++) + { + somme = somme + 1; + } + printf("Le nombre total d'adhérents est de %d.\n", somme); +} \ No newline at end of file diff --git a/SAE.h b/Fonctions.h similarity index 94% rename from SAE.h rename to Fonctions.h index 1b02417..ea00b4e 100644 --- a/SAE.h +++ b/Fonctions.h @@ -14,7 +14,7 @@ int choixMenuAffichage(void); /* Fonctions d'affichage */ void Affichage1Adherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem); void AffichageTousAdherents(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem); -void AffichageNbEntreesTousJours(int tNbActivitesJour[], int tDate[], int nbelem); +void AffichageNbEntreesTousJour(int tNbActivitesJour[], int tDate[], int nbelem); void AffichageNbEntreesTotal(int tNbActivitesJour[], int nbelem); void AffichageNbAdherents(int nbelem); diff --git a/GestionAdherents.c b/GestionAdherents.c new file mode 100644 index 0000000..a5ae364 --- /dev/null +++ b/GestionAdherents.c @@ -0,0 +1,129 @@ +#include "Fonctions.h" + +int rechercheAdherent(int tNoCarte[], int nbelem, int NoCarte, int *trouve) +{ + int i; + for(i = 0; i < nbelem; i++) + { + if(tNoCarte[i] == NoCarte) + { + *trouve = 1; + return i; + } + if(tNoCarte[i] > NoCarte) + { + *trouve = 0; + return i + 1; + } + } +} + +int AjoutAdherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tmax, int nbelem) +{ + int NoCarte, age, pointsCarte, CarteActive, pas, trouve, j; + char reponse; + printf("Donnez l'âge de l'adhérent :\n"); + scanf("%d", &age); + pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); + printf("%d\n", pas); + for(j=nbelem; j> pas; j--) + { + if(j == tmax) + { + printf("Tableau plein, impossible d'ajouter un adhérent\n"); + return -1; + } + tNoCarte[j] = tNoCarte[j-1]; + tage[j] = tage[j-1]; + tPointsCarte[j] = tPointsCarte[j-1]; + tCarteActive[j] = tCarteActive[j-1]; + } + tNoCarte[pas] = pas + 1; + printf("%d\n", tNoCarte[pas]); + tage[pas] = age; + tPointsCarte[pas] = 0; + tCarteActive[pas] = 0; + nbelem++; + printf("Le numero de carte de l'adherent qui a %d ans est %d.\nLa carte n'est pas active car il n'y a pas de points dessus.\nVoulez-vous en ajouter ? (O / N)", tage[pas], tNoCarte[pas]); + scanf("%*c%c", &reponse); + if(reponse == 'O' || reponse == 'o') + { + AjoutPoints(tNoCarte, tPointsCarte, tCarteActive, nbelem); + } + else + { + printf("La carte n'est pas active.\n"); + return nbelem; + } + return nbelem; +} + +void ModificationAge(int tNoCarte[], int tage[], int nbelem) +{ + int pas, NoCarte, age, trouve; + printf("Entrez le numéro de la carte de l'adhérent recherché : "); + scanf("%d",&NoCarte); + pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); + if(trouve == 1) + { + printf("Entrez l'age de l'adhérent : "); + scanf("%d",&age); + tage[pas] = age; + } + else + { + printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); + return; + } +} + +int SupprimmerAdherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem) +{ + int pas, i, NoCarte, trouve; + printf("Entrez le numéro de la carte de l'adhérent recherché : "); + scanf("%d",&NoCarte); + pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); + if(trouve == 1) + { + for(i = pas; i < nbelem; i++) + { + tNoCarte[i] = tNoCarte[i+1]; + tage[i] = tage[i+1]; + tPointsCarte[i] = tPointsCarte[i+1]; + tCarteActive[i] = tCarteActive[i+1]; + } + nbelem = nbelem - 1; + return nbelem; + } + else + { + printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); + return -1; + } +} + +void ModificationActivationCarte(int tNoCarte[], int tCarteActive[], int nbelem) +{ + int NoCarte, trouve, pas; + printf("Entrez le numéro de la carte de l'adhérent recherché : "); + scanf("%d",&NoCarte); + pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); + if(trouve == 1) + { + if(tCarteActive[pas] == 1) + { + tCarteActive[pas] = 0; + printf("La carte est desactivée.\n"); + } + else + { + tCarteActive[pas] = 1; + printf("La carte est activée.\n"); + } + } + else + { + printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); + return; + } +} \ No newline at end of file diff --git a/GestionPoints.c b/GestionPoints.c new file mode 100644 index 0000000..b9ef56e --- /dev/null +++ b/GestionPoints.c @@ -0,0 +1,97 @@ +#include "Fonctions.h" + +void AjoutPoints(int tNoCarte[], int tPointsCarte[], int tCarteActive[], int nbelem) +{ + int pointsCarte, NoCarte, trouve, pas; + printf("Entrez le numéro de la carte de l'adhérent recherché : "); + scanf("%d",&NoCarte); + pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); + if(trouve == 1) + { + printf("Entrez le nombre de points a ajouter: "); + scanf("%d", &pointsCarte); + if(pointsCarte > 0 && pointsCarte <= 20) + { + tPointsCarte[pas] = pointsCarte; + tCarteActive[pas] = 1; + printf("La carte est active.\n"); + } + else + if(pointsCarte > 20 && pointsCarte <= 50) + { + tPointsCarte[pas] = pointsCarte + pointsCarte*(1 + (5/100.0)); + tCarteActive[pas] = 1; + printf("Merci pour votre achat. Nous vous offrons 5%% supplémentaires. De plus, votre carte est active.\n"); + } + else + if(pointsCarte > 50 && pointsCarte <= 100) + { + tPointsCarte[pas] = pointsCarte + pointsCarte*(1 + (10/100.0)); + tCarteActive[pas] = 1; + printf("Merci pour votre achat. Nous vous offrons 10%% supplémentaires. De plus, votre carte est active.\n"); + } + else + if(pointsCarte > 100) + { + tPointsCarte[pas] = pointsCarte + pointsCarte*(1 + (15/100.0)); + tCarteActive[pas] = 1; + printf("Merci pour votre achat. Nous vous offrons 15%% supplémentaires. De plus, votre carte est active.\n"); + } + else + { + printf("Le nombre de points est incorrect.\n"); + printf("Veuillez ressaisir le nombre de points a ajouter: "); + scanf("%d", &pointsCarte); + } + } + else + { + printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); + return; + } +} + +void DebitActivitee(int tNoCarte[], int tCarteActive[], int tNbActivitesJour[], int nbelem) +{ + int NoCarte, trouve, pas, pointsCarte; + char reponse; + printf("Entrez le numéro de la carte de l'adhérent recherché : "); + scanf("%d",&NoCarte); + pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); + if(trouve == 1) + { + if(tCarteActive[pas] == 1) + { + printf("Voulez-vous desactiver cette carte ? (O/N)\n"); + scanf("%*c%c", &reponse); + if(reponse == 'O' || reponse == 'o') + { + tCarteActive[pas] = 0; + printf("La carte est desactivée.\n"); + } + else + { + printf("La carte est toujours active.\n"); + } + } + else + { + printf("La carte est desactivée. Voulez-vous la réactiver ? (O/N)\n"); + scanf("%*c%c", &reponse); + if(reponse == 'O' || reponse == 'o') + { + tCarteActive[pas] = 1; + printf("La carte est activée.\n"); + } + else + { + printf("La carte est toujours desactivée.\n"); + } + } + } + else + { + printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); + return; + } +} \ No newline at end of file diff --git a/Global.c b/Global.c new file mode 100644 index 0000000..f2aa5b1 --- /dev/null +++ b/Global.c @@ -0,0 +1,75 @@ +#include "Fonctions.h" + +void gestionMenus(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; + char choixA; + nbelem = Ouverture(tNoCarte, tage, tPointsCarte, tCarteActive, tNbActivitesJour, tDate, tmax, &pasAct); + if (nbelem < 0) + { + printf("Erreur d'ouverture du fichier ou tableau plein !!!\n"); + return; + } + choix = choixMenu(); + while (choix != 8) + { + if (choix == 1) + { + choixA = choixMenuAffichage(); + while (choixA != 'F' && choixA != 'f') + { + if (choixA == 'A' || choixA == 'a') + { + Affichage1Adherent(tNoCarte, tage, tPointsCarte, tCarteActive, nbelem); + } + if (choixA == 'B' || choixA == 'b') + { + AffichageTousAdherents(tNoCarte, tage, tPointsCarte, tCarteActive, nbelem); + } + if (choixA == 'C' || choixA == 'c') + { + AffichageNbEntreesTousJour(tNbActivitesJour, tDate, nbelem); + } + if (choixA == 'D' || choixA == 'd') + { + AffichageNbEntreesTotal(tNbActivitesJour, nbelem); + } + if (choixA == 'E' || choixA == 'e') + { + AffichageNbAdherents(nbelem); + } + choixA = choixMenuAffichage(); + } + } + if (choix == 2) + { + nbelem = AjoutAdherent(tNoCarte, tage, tPointsCarte, tCarteActive, tmax, nbelem); + } + if (choix == 3) + { + ModificationAge(tNoCarte, tage, nbelem); + } + if (choix == 4) + { + nbelem = SupprimmerAdherent(tNoCarte, tage, tPointsCarte, tCarteActive, nbelem); + } + if (choix == 5) + { + + AjoutPoints(tNoCarte, tPointsCarte, tCarteActive, nbelem); + } + if (choix == 6) + { + ModificationActivationCarte(tNoCarte, tCarteActive, nbelem); + } + if (choix == 7) + { + DebitActivitee(tNoCarte, tCarteActive, tNbActivitesJour, nbelem); + } + choix = choixMenu(); + } + Sauvegarde(tNoCarte, tage, tPointsCarte, tCarteActive, tNbActivitesJour, tDate, nbelem); + exit(1); +} \ No newline at end of file diff --git a/Menus.c b/Menus.c new file mode 100644 index 0000000..f576b93 --- /dev/null +++ b/Menus.c @@ -0,0 +1,33 @@ +#include "Fonctions.h" + +int choixMenu(void) +{ + int choix; + printf("\t Gestion des matières\n"); + printf("1.\tAffichage\n"); + printf("2.\tAjouter un adhérent\n"); + printf("3.\tModifier l'âge d'un adhérent\n"); + printf("4.\tSuppression d'un adhérent\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; +} + +int choixMenuAffichage(void) +{ + char choix; + printf("\t Gestion des matières\n"); + printf("A.\tAffichage des informations d'un adhérent\n"); + printf("B.\tAffichage des informations de tous les adhérents\n"); + printf("C.\tAffichage du nombre d’entrées totale de toutes les journée\n"); + printf("D.\tAffichage du nombre d'entrées totale depuis le début\n"); + printf("E.\tAffichage du nombre total d'adhérents\n"); + printf("F.\tquitter\n"); + printf("\noption choisie :\n"); + scanf("%*c%c", &choix); + return choix; +} \ No newline at end of file diff --git a/Ouverture.c b/Ouverture.c new file mode 100644 index 0000000..6ab8883 --- /dev/null +++ b/Ouverture.c @@ -0,0 +1,69 @@ +#include "Fonctions.h" + +int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int tmax, int *pasAct) +{ + int pasMembres; + pasMembres = OuvertureMembres(tNoCarte, tage, tPointsCarte, tCarteActive, tmax); + *pasAct = OuvertureActivitesJour(tNbActivitesJour, tDate, tmax); + return pasMembres; +} + +int OuvertureMembres(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tmax) +{ + int i = 0; + int NoCarte, age, pointsCarte, CarteActive; + FILE *flot; + flot = fopen("membres.don", "r"); + if (flot == NULL) + { + printf("Pb d'ouverture du fichier membres.don\n"); + return -1; + } + fscanf(flot, "%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive); + while (!feof(flot)) + { + if (i == tmax) + { + printf("Tableau plein\n"); + fclose(flot); + return -1; + } + tNoCarte[i] = NoCarte; + tage[i] = age; + tPointsCarte[i] = pointsCarte; + tCarteActive[i] = 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 (i == tmax) + { + printf("Tableau plein\n"); + fclose(jour); + return -1; + } + tDate[i] = Date; + tNbActivitesJour[i] = nbActivitesJour; + fscanf(jour, "%d%d", &Date, &nbActivitesJour); + i++; + } + fclose(jour); + return i; +} \ No newline at end of file diff --git a/SAE.c b/SAE.c deleted file mode 100644 index 388afd4..0000000 --- a/SAE.c +++ /dev/null @@ -1,486 +0,0 @@ -#include "SAE.h" - -int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int tmax, int *pasAct) -{ - int pasMembres; - pasMembres = OuvertureMembres(tNoCarte, tage, tPointsCarte, tCarteActive, tmax); - *pasAct = OuvertureActivitesJour(tNbActivitesJour, tDate, tmax); - return pasMembres; -} - -int OuvertureMembres(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tmax) -{ - int i = 0; - int NoCarte, age, pointsCarte, CarteActive; - FILE *flot; - flot = fopen("membres.don", "r"); - if (flot == NULL) - { - printf("Pb d'ouverture du fichier membres.don\n"); - return -1; - } - fscanf(flot, "%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive); - while (!feof(flot)) - { - if (i == tmax) - { - printf("Tableau plein\n"); - fclose(flot); - return -1; - } - tNoCarte[i] = NoCarte; - tage[i] = age; - tPointsCarte[i] = pointsCarte; - tCarteActive[i] = 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 (i == tmax) - { - printf("Tableau plein\n"); - fclose(jour); - return -1; - } - tDate[i] = Date; - tNbActivitesJour[i] = nbActivitesJour; - fscanf(jour, "%d%d", &Date, &nbActivitesJour); - i++; - } - fclose(jour); - return i; -} - -int choixMenu(void) -{ - int choix; - printf("\t Gestion des matières\n"); - printf("1.\tAffichage\n"); - printf("2.\tAjouter un adhérent\n"); - printf("3.\tModifier l'âge d'un adhérent\n"); - printf("4.\tSuppression d'un adhérent\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; -} - -int choixMenuAffichage(void) -{ - char choix; - printf("\t Gestion des matières\n"); - printf("A.\tAffichage des informations d'un adhérent\n"); - printf("B.\tAffichage des informations de tous les adhérents\n"); - printf("C.\tAffichage du nombre d’entrées totale de toutes les journée\n"); - printf("D.\tAffichage du nombre d'entrées totale depuis le début\n"); - printf("E.\tAffichage du nombre total d'adhérents\n"); - printf("F.\tquitter\n"); - printf("\noption choisie :\n"); - scanf("%*c%c", &choix); - return choix; -} - -int rechercheAdherent(int tNoCarte[], int nbelem, int NoCarte, int *trouve) -{ - int i; - for(i = 0; i < nbelem; i++) - { - if(tNoCarte[i] == NoCarte) - { - *trouve = 1; - return i; - } - if(tNoCarte[i] > NoCarte) - { - *trouve = 0; - return i + 1; - } - } -} - -int AjoutAdherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tmax, int nbelem) -{ - int NoCarte, age, pointsCarte, CarteActive, pas, trouve, j; - char reponse; - printf("Donnez l'âge de l'adhérent :\n"); - scanf("%d", &age); - pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); - printf("%d\n", pas); - for(j=nbelem; j> pas; j--) - { - if(j == tmax) - { - printf("Tableau plein, impossible d'ajouter un adhérent\n"); - return -1; - } - tNoCarte[j] = tNoCarte[j-1]; - tage[j] = tage[j-1]; - tPointsCarte[j] = tPointsCarte[j-1]; - tCarteActive[j] = tCarteActive[j-1]; - } - tNoCarte[pas] = pas + 1; - printf("%d\n", tNoCarte[pas]); - tage[pas] = age; - tPointsCarte[pas] = 0; - tCarteActive[pas] = 0; - nbelem++; - printf("Le numero de carte de l'adherent qui a %d ans est %d.\nLa carte n'est pas active car il n'y a pas de points dessus.\nVoulez-vous en ajouter ? (O / N)", tage[pas], tNoCarte[pas]); - scanf("%*c%c", &reponse); - if(reponse == 'O' || reponse == 'o') - { - AjoutPoints(tNoCarte, tPointsCarte, tCarteActive, nbelem); - } - else - { - printf("La carte n'est pas active.\n"); - return nbelem; - } - return nbelem; -} - -void Affichage1Adherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem) -{ - int pas, NoCarte, CarteActive, trouve; - printf("Entrez le numéro de la carte de l'adhérent recherché : "); - scanf("%d",&NoCarte); - pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); - if(trouve == 1) - { - printf(" N°_de_carte\tAge Points Carte_active\n"); - printf("\t%d\t%d\t%d\t%d\n", tNoCarte[pas], tage[pas], tPointsCarte[pas], tCarteActive[pas]); - } - else - { - printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); - return; - } -} - -void AffichageTousAdherents(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem) -{ - int i; - printf(" N°_de_carte\tAge Points Carte_active\n"); - for (i = 0; i < nbelem; i++) - { - printf("\t%d\t%d\t%d\t%d\n", tNoCarte[i], tage[i], tPointsCarte[i], tCarteActive[i]); - } -} - -void AffichageNbEntreesTousJour(int tNbActivitesJour[], int tDate[], int nbelem) -{ - int i; - printf(" Date\tNb_Activites\n"); - for (i = 0; i < nbelem; i++) - { - printf("\t%d\t%d\n", tDate[i], tNbActivitesJour[i]); - } -} - -void AffichageNbEntreesTotal(int tNbActivitesJour[], int nbelem) -{ - int i, somme = 0; - for (i = 0; i < nbelem; i++) - { - somme = somme + tNbActivitesJour[i]; - } - printf("Le nombre total d'entrées est de %d depuis le début.\n", somme); -} - -void AffichageNbAdherents(int nbelem) -{ - int i, somme = 0; - for (i = 0; i < nbelem; i++) - { - somme = somme + 1; - } - printf("Le nombre total d'adhérents est de %d.\n", somme); -} - -void gestionMenus(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; - char choixA; - nbelem = Ouverture(tNoCarte, tage, tPointsCarte, tCarteActive, tNbActivitesJour, tDate, tmax, &pasAct); - if (nbelem < 0) - { - printf("Erreur d'ouverture du fichier ou tableau plein !!!\n"); - return; - } - choix = choixMenu(); - while (choix != 8) - { - if (choix == 1) - { - choixA = choixMenuAffichage(); - while (choixA != 'F' && choixA != 'f') - { - if (choixA == 'A' || choixA == 'a') - { - Affichage1Adherent(tNoCarte, tage, tPointsCarte, tCarteActive, nbelem); - } - if (choixA == 'B' || choixA == 'b') - { - AffichageTousAdherents(tNoCarte, tage, tPointsCarte, tCarteActive, nbelem); - } - if (choixA == 'C' || choixA == 'c') - { - AffichageNbEntreesTousJour(tNbActivitesJour, tDate, nbelem); - } - if (choixA == 'D' || choixA == 'd') - { - AffichageNbEntreesTotal(tNbActivitesJour, nbelem); - } - if (choixA == 'E' || choixA == 'e') - { - AffichageNbAdherents(nbelem); - } - choixA = choixMenuAffichage(); - } - } - if (choix == 2) - { - nbelem = AjoutAdherent(tNoCarte, tage, tPointsCarte, tCarteActive, tmax, nbelem); - } - if (choix == 3) - { - ModificationAge(tNoCarte, tage, nbelem); - } - if (choix == 4) - { - nbelem = SupprimmerAdherent(tNoCarte, tage, tPointsCarte, tCarteActive, nbelem); - } - if (choix == 5) - { - - AjoutPoints(tNoCarte, tPointsCarte, tCarteActive, nbelem); - } - if (choix == 6) - { - ModificationActivationCarte(tNoCarte, tCarteActive, nbelem); - } - if (choix == 7) - { - DebitActivitee(tNoCarte, tCarteActive, tNbActivitesJour, nbelem); - } - choix = choixMenu(); - } - Sauvegarde(tNoCarte, tage, tPointsCarte, tCarteActive, tNbActivitesJour, tDate, nbelem); - exit(1); -} - -void ModificationAge(int tNoCarte[], int tage[], int nbelem) -{ - int pas, NoCarte, age, trouve; - printf("Entrez le numéro de la carte de l'adhérent recherché : "); - scanf("%d",&NoCarte); - pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); - if(trouve == 1) - { - printf("Entrez l'age de l'adhérent : "); - scanf("%d",&age); - tage[pas] = age; - } - else - { - printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); - return; - } -} - -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 SupprimmerAdherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem) -{ - int pas, i, NoCarte, trouve; - printf("Entrez le numéro de la carte de l'adhérent recherché : "); - scanf("%d",&NoCarte); - pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); - if(trouve == 1) - { - for(i = pas; i < nbelem; i++) - { - tNoCarte[i] = tNoCarte[i+1]; - tage[i] = tage[i+1]; - tPointsCarte[i] = tPointsCarte[i+1]; - tCarteActive[i] = tCarteActive[i+1]; - } - nbelem = nbelem - 1; - return nbelem; - } - else - { - printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); - return -1; - } - -} - -void AjoutPoints(int tNoCarte[], int tPointsCarte[], int tCarteActive[], int nbelem) -{ - int pointsCarte, NoCarte, trouve, pas; - printf("Entrez le numéro de la carte de l'adhérent recherché : "); - scanf("%d",&NoCarte); - pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); - if(trouve == 1) - { - printf("Entrez le nombre de points a ajouter: "); - scanf("%d", &pointsCarte); - if(pointsCarte > 0 && pointsCarte <= 20) - { - tPointsCarte[pas] = pointsCarte; - tCarteActive[pas] = 1; - printf("La carte est active.\n"); - } - else - if(pointsCarte > 20 && pointsCarte <= 50) - { - tPointsCarte[pas] = pointsCarte + pointsCarte*(1 + (5/100.0)); - tCarteActive[pas] = 1; - printf("Merci pour votre achat. Nous vous offrons 5%% supplémentaires. De plus, votre carte est active.\n"); - } - else - if(pointsCarte > 50 && pointsCarte <= 100) - { - tPointsCarte[pas] = pointsCarte + pointsCarte*(1 + (10/100.0)); - tCarteActive[pas] = 1; - printf("Merci pour votre achat. Nous vous offrons 10%% supplémentaires. De plus, votre carte est active.\n"); - } - else - if(pointsCarte > 100) - { - tPointsCarte[pas] = pointsCarte + pointsCarte*(1 + (15/100.0)); - tCarteActive[pas] = 1; - printf("Merci pour votre achat. Nous vous offrons 15%% supplémentaires. De plus, votre carte est active.\n"); - } - else - { - printf("Le nombre de points est incorrect.\n"); - printf("Veuillez ressaisir le nombre de points a ajouter: "); - scanf("%d", &pointsCarte); - } - } - else - { - printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); - return; - } -} - -void DebitActivitee(int tNoCarte[], int tCarteActive[], int tNbActivitesJour[], int nbelem) -{ - int NoCarte, trouve, pas, pointsCarte; - char reponse; - printf("Entrez le numéro de la carte de l'adhérent recherché : "); - scanf("%d",&NoCarte); - pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); - if(trouve == 1) - { - if(tCarteActive[pas] == 1) - { - printf("Voulez-vous desactiver cette carte ? (O/N)\n"); - scanf("%*c%c", &reponse); - if(reponse == 'O' || reponse == 'o') - { - tCarteActive[pas] = 0; - printf("La carte est desactivée.\n"); - } - else - { - printf("La carte est toujours active.\n"); - } - } - else - { - printf("La carte est desactivée. Voulez-vous la réactiver ? (O/N)\n"); - scanf("%*c%c", &reponse); - if(reponse == 'O' || reponse == 'o') - { - tCarteActive[pas] = 1; - printf("La carte est activée.\n"); - } - else - { - printf("La carte est toujours desactivée.\n"); - } - } - } - else - { - printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); - return; - } -} - -void ModificationActivationCarte(int tNoCarte[], int tCarteActive[], int nbelem) -{ - int NoCarte, trouve, pas; - printf("Entrez le numéro de la carte de l'adhérent recherché : "); - scanf("%d",&NoCarte); - pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); - if(trouve == 1) - { - if(tCarteActive[pas] == 1) - { - tCarteActive[pas] = 0; - printf("La carte est desactivée.\n"); - } - else - { - tCarteActive[pas] = 1; - printf("La carte est activée.\n"); - } - } - else - { - printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); - return; - } -} \ No newline at end of file diff --git a/Sauvegarde.c b/Sauvegarde.c new file mode 100644 index 0000000..123925d --- /dev/null +++ b/Sauvegarde.c @@ -0,0 +1,29 @@ +#include "Fonctions.h" + +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); +} \ No newline at end of file diff --git a/exe b/exe index 488a2b3e60948c28ddb669b7a5e5047188a5a4a7..40475d15f6eb46723845fd7a96e3d9e6c2cec97c 100755 GIT binary patch delta 6262 zcmZ`-3s_ZE7T)Iq^6=`tAR-_NiU{~Z88M#-!X2-ur75K)$m^z*JU#@=(ykNggf}Le zZEyRg={=2om1J6(k&@;U?dhmvXlCbz6)D;!&@=zq=i$Mc{eAbWwf^7!n}uWe)wTW;TRIX%5Ww(PgKwV*+2F!olc%Cy~p zS8DjuN>#7h>+JYkOt{_+(m73dh;9rz$AtGZa2sO_ObTm5=;%E` zf42v@7bDWT#%hal)LGjUw8wBz(#}GqB%H(57MlT%@E#TNXCzZ= zyp2LWKr*$&`<9S*lZ;j{@AE=_pX4dj0`EovY$br!$-73#uaiuz@Ky@>1(K-+-U1<~ zF6K@45lI12$g}VHe8$>svDql6eo84Uo%I1lL?-yE`#L=VyYhKtXiSh$q``A?XiPR- zsP-VGN=;n|ug9Z<2Flw4=+loiA}>%ObDIz3ZPK#)gbc6li-djpQ;^Ua}S z`02>NxuZuhwu8Lo2d^oLv)lUHN-E!%1=ezV@)$m zW3KXf(Me%5NqM+SQT92yD6!ToE=Ba^FGR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N`BbA4MD1m$c?!=BF)E_d2P0Ex{We4RM}8Gx(~x(Xn*TP-!k` zOVu~NU1S)BRZu2(_EG|H^2&}9A(^;m!TzY>?`c2IIi;GV(_E%}dip<1mBFbBcg+G9 zYK~#^bTiF*krw4hj0D;=yh+Q|o+JVK5~i_=;?SPw36Y7fIIYj3Tmo3c*(htAa!M83Q5u{(U zE#rCf(viKjol}Z<+%iLIE8^3-C2tYm3TdXC_55Vs49O`aR?Oon49Qu{r*%u^#e8c; ruBn(eSL8+%OZ!Ic%YwdvGkE&)p+WPWkQ&9p%a)HY7nky_%TxXjejc(b diff --git a/testSAE.c b/main.c similarity index 98% rename from testSAE.c rename to main.c index 77b6051..55d7707 100644 --- a/testSAE.c +++ b/main.c @@ -1,4 +1,4 @@ -#include "SAE.h" +#include "Fonctions.h" void testOuverture(void) { diff --git a/membres.don b/membres.don index a92bc92..0646c94 100644 --- a/membres.don +++ b/membres.don @@ -7,3 +7,11 @@ 7 36 6 0 8 19 2 1 9 21 1 1 + 1 22 10 0 + 2 25 5 1 + 3 47 7 1 + 4 38 8 1 + 5 18 8 1 + 6 46 6 1 + 7 36 6 0 + 8 19 2 1