diff --git a/ActivitesJour.don b/ActivitesJour.don index e6eb2bd..b9d8a67 100644 --- a/ActivitesJour.don +++ b/ActivitesJour.don @@ -7,11 +7,3 @@ 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/SAE.c b/SAE.c index 2f8ff2f..388afd4 100644 --- a/SAE.c +++ b/SAE.c @@ -87,16 +87,16 @@ int choixMenu(void) int choixMenuAffichage(void) { - int choix; + char choix; printf("\t Gestion des matières\n"); - printf("1.\tAffichage des informations d'un adhérent\n"); - printf("2.\tAffichage des informations de tous les adhérents\n"); - printf("3.\tAffichage du nombre d’entrées totale de toutes les journée\n"); - printf("4.\tAffichage du nombre d'entrées totale depuis le début\n"); - printf("5.\tAffichage du nombre total d'adhérents\n"); - printf("6.\tquitter\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("%d", &choix); + scanf("%*c%c", &choix); return choix; } @@ -113,17 +113,57 @@ int rechercheAdherent(int tNoCarte[], int nbelem, int NoCarte, int *trouve) if(tNoCarte[i] > NoCarte) { *trouve = 0; - return i; + 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 = rechercheAdherant(tNoCarte, nbelem, NoCarte, &trouve); + pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); if(trouve == 1) { printf(" N°_de_carte\tAge Points Carte_active\n"); @@ -181,6 +221,7 @@ 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) { @@ -192,30 +233,30 @@ void gestionMenus(void) { if (choix == 1) { - choix = choixMenuAffichage(); - while (choix != 6) + choixA = choixMenuAffichage(); + while (choixA != 'F' && choixA != 'f') { - if (choix == 1) + if (choixA == 'A' || choixA == 'a') { Affichage1Adherent(tNoCarte, tage, tPointsCarte, tCarteActive, nbelem); } - if (choix == 2) + if (choixA == 'B' || choixA == 'b') { AffichageTousAdherents(tNoCarte, tage, tPointsCarte, tCarteActive, nbelem); } - if (choix == 3) + if (choixA == 'C' || choixA == 'c') { AffichageNbEntreesTousJour(tNbActivitesJour, tDate, nbelem); } - if (choix == 4) + if (choixA == 'D' || choixA == 'd') { AffichageNbEntreesTotal(tNbActivitesJour, nbelem); } - if (choix == 5) + if (choixA == 'E' || choixA == 'e') { AffichageNbAdherents(nbelem); } - choix = choixMenuAffichage(); + choixA = choixMenuAffichage(); } } if (choix == 2) @@ -233,7 +274,7 @@ void gestionMenus(void) if (choix == 5) { - AjoutPoints(tNoCarte, tPointsCarte, nbelem); + AjoutPoints(tNoCarte, tPointsCarte, tCarteActive, nbelem); } if (choix == 6) { @@ -241,7 +282,7 @@ void gestionMenus(void) } if (choix == 7) { - DebitActivitee(tNoCarte, tPointsCarte, tNbActivitesJour, tDate, nbelem, &pasAct); + DebitActivitee(tNoCarte, tCarteActive, tNbActivitesJour, nbelem); } choix = choixMenu(); } @@ -251,10 +292,10 @@ void gestionMenus(void) void ModificationAge(int tNoCarte[], int tage[], int nbelem) { - int pas, NoCarte, age; + int pas, NoCarte, age, trouve; printf("Entrez le numéro de la carte de l'adhérent recherché : "); scanf("%d",&NoCarte); - pas = rechercheAdherant(tNoCarte, nbelem, NoCarte, &trouve); + pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); if(trouve == 1) { printf("Entrez l'age de l'adhérent : "); @@ -268,12 +309,40 @@ void ModificationAge(int tNoCarte[], int tage[], int nbelem) } } +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 = rechercheAdherant(tNoCarte, nbelem, NoCarte, &trouve); + pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); if(trouve == 1) { for(i = pas; i < nbelem; i++) @@ -294,89 +363,54 @@ int SupprimmerAdherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCart } -int AjoutAdherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tmax, int nbelem) +void AjoutPoints(int tNoCarte[], int tPointsCarte[], int tCarteActive[], int nbelem) { - int NoCarte, age, pointsCarte, CarteActive, pas; - char reponse; - printf("Donnez l'âge de l'adhérent :\n"); - scanf("%d", &age); - pas = rechercheAdherant(tNoCarte, nbelem); - 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; - 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, pas); - } - else - { - printf("La carte n'est pas active.\n"); - return nbelem; - } - return nbelem; -} - -void AjoutPoints(int tNoCarte[], int tPointsCarte[], int tCarteActive[], int nbelem, int pas) -{ - int pointsCarte, NoCarte, trouve; + int pointsCarte, NoCarte, trouve, pas; printf("Entrez le numéro de la carte de l'adhérent recherché : "); scanf("%d",&NoCarte); - pas = rechercheAdherant(tNoCarte, nbelem, NoCarte, &trouve); + 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"); - } - 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"); - } - 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"); - } - 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); - } + 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 -1; + return; } } @@ -386,7 +420,7 @@ void DebitActivitee(int tNoCarte[], int tCarteActive[], int tNbActivitesJour[], char reponse; printf("Entrez le numéro de la carte de l'adhérent recherché : "); scanf("%d",&NoCarte); - pas = rechercheAdherant(tNoCarte, nbelem, NoCarte, &trouve); + pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); if(trouve == 1) { if(tCarteActive[pas] == 1) @@ -421,7 +455,7 @@ void DebitActivitee(int tNoCarte[], int tCarteActive[], int tNbActivitesJour[], else { printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); - return -1; + return; } } @@ -430,7 +464,7 @@ 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 = rechercheAdherant(tNoCarte, nbelem, NoCarte, &trouve); + pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve); if(trouve == 1) { if(tCarteActive[pas] == 1) @@ -447,6 +481,6 @@ void ModificationActivationCarte(int tNoCarte[], int tCarteActive[], int nbelem) else { printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); - return -1; + return; } } \ No newline at end of file diff --git a/SAE.h b/SAE.h index 5badddf..1b02417 100644 --- a/SAE.h +++ b/SAE.h @@ -26,12 +26,12 @@ int Sauvegarde(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[ void testSauvegarde(void); /* Fonctions de gestion des adherents */ -int rechercheAdherant (int tNoCarte[], int nbelem, int NoCarte, int *trouve); +int rechercheAdherent (int tNoCarte[], int nbelem, int NoCarte, int *trouve); int AjoutAdherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tmax, int nbelem); void ModificationAge(int tNoCarte[], int tage[], int nbelem); int SupprimmerAdherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem); void ModificationActivationCarte(int tNoCarte[], int tCarteActive[], int nbelem); /* Fonctions de gestion des points */ -void AjoutPoints(int tNoCarte[], int tPointsCarte[], int tCarteActive[], int nbelem, int pas); +void AjoutPoints(int tNoCarte[], int tPointsCarte[], int tCarteActive[], int nbelem); void DebitActivitee(int tNoCarte[], int tCarteActive[], int tNbActivitesJour[], int nbelem); \ No newline at end of file diff --git a/exe b/exe index 35b2804..488a2b3 100755 Binary files a/exe and b/exe differ diff --git a/membres.don b/membres.don index 0646c94..a92bc92 100644 --- a/membres.don +++ b/membres.don @@ -7,11 +7,3 @@ 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