diff --git a/SAE.c b/SAE.c index 5e11d16..1ef3001 100644 --- a/SAE.c +++ b/SAE.c @@ -38,6 +38,7 @@ int OuvertureMembres(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteA fclose(flot); return i; } + int OuvertureActivitesJour(int tNbActivitesJour[], int tDate[], int tmax) { int i = 0; @@ -117,26 +118,6 @@ int rechercheAdherent(int tNoCarte[], int nbelem, int NoCarte, int *trouve) } } -int rechercheAdherent(int tNoCarte[], int tmax, int nbelem) -{ - int i = 0, NoCarte; - printf("Entrez le numéro de la carte de l'adhérent recherché : "); - scanf("%d",&NoCarte); - while (i < tmax && tNoCarte[i] != NoCarte) - { - i++; - } - if (i == tmax) - { - printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); - return -1; - } - else - { - return i; - } -} - void Affichage1Adherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem) { int pas, NoCarte, CarteActive, trouve; @@ -164,6 +145,7 @@ void AffichageTousAdherents(int tNoCarte[], int tage[], int tPointsCarte[], int 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; @@ -173,6 +155,7 @@ void AffichageNbEntreesTousJour(int tNbActivitesJour[], int tDate[], int nbelem) printf("\t%d\t%d\n", tDate[i], tNbActivitesJour[i]); } } + void AffichageNbEntreesTotal(int tNbActivitesJour[], int nbelem) { int i, somme = 0; @@ -254,10 +237,11 @@ void gestionMenus(void) } if (choix == 6) { - + ModificationActivationCarte(tNoCarte, tCarteActive, nbelem); } if (choix == 7) { + DebitActivitee(tNoCarte, tPointsCarte, tNbActivitesJour, tDate, nbelem, &pasAct); } choix = choixMenu(); } @@ -396,35 +380,7 @@ void AjoutPoints(int tNoCarte[], int tPointsCarte[], int tCarteActive[], int nbe } } -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 DebitActivitee(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int nbelem) +void DebitActivitee(int tNoCarte[], int tPointsCarte[], int tNbActivitesJour[], int tDate[], int nbelem, int *pasAct) { int NoCarte, trouve, pas, pointsCarte; char reponse; @@ -469,84 +425,7 @@ void DebitActivitee(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteAc } } -void modificationEtat(int tNumCarte[], int tEtat[], int tailleLog) -{ - int choix, numCarte, index, trouve; - printf("Que voulez-vous faire ?\n1.\tActiver une carte\n2.\tDésactiver une carte"); - scanf("%d", &choix); - while (choix != 1 || choix != 2) - { - printf("Choix invalide. Veuillez réessayer.\nQue voulez-vous faire ?\n1.\tActiver une carte\n2.\tDésactiver une carte"); - scanf("%d", &choix); - } - - printf("Entrez le numéro de la carte dont vous voulez modifier l'état."); - scanf("%d", &numCarte); - index = recherche(tNumCarte, tailleLog, numCarte, &trouve); - while (trouve == 0) - { - printf("Numéro de carte non trouvé. Veuillez réessayer.\nEntrez le numéro d'adhérent : "); - scanf("%d", &numCarte); - index = recherche(tNumCarte, tailleLog, numCarte, &trouve); - } - - if (choix == 1) - { - if (tEtat[index] == 1) - { - printf("La carte n°%d est déjà active", numCarte); - return; - } - else - { - printf("La carte n°%d a été activée", numCarte); - return; - } - } - else if (choix == 2) - { - if (tEtat[index] == 0) - { - printf("La carte n°%d est déjà désactivée", numCarte); - return; - } - else - { - printf("La carte n°%d a été désactivée.", numCarte) - 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); -} - -/*void ModificationActivationCarte(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem) +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é : "); @@ -570,7 +449,7 @@ int Sauvegarde(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[ printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n"); return -1; } -}*/ +} void DebitActivitee(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int nbelem) { diff --git a/SAE.h b/SAE.h index 4b19629..4a7ab8d 100644 --- a/SAE.h +++ b/SAE.h @@ -26,7 +26,7 @@ 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 rechercheAdherant (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); void modificationEtat(int tNumCarte[], int tEtat[], int tailleLog);