From 668f83328193566a38773b8e05e1f6af0d283fa4 Mon Sep 17 00:00:00 2001 From: Antoine PEREDERII Date: Wed, 9 Nov 2022 16:36:13 +0100 Subject: [PATCH] Ajout des fonctions ajouts de points sur la carte, recherche et creation d'un adherant --- ActivitesJour.don | 21 ++++++------ SAE.c | 83 ++++++++++++++++++++++++++++++++++++++++------ exe | Bin 17048 -> 17048 bytes membres.don | 18 +++++----- testSAE.c | 4 +-- 5 files changed, 94 insertions(+), 32 deletions(-) diff --git a/ActivitesJour.don b/ActivitesJour.don index 5bad8fd..af64d63 100644 --- a/ActivitesJour.don +++ b/ActivitesJour.don @@ -1,11 +1,10 @@ -Date nbActivitesJour -13052022 120 -0 0 -5 5 -7 7 -8 8 -8 8 -6 6 -6 6 -2 2 -1 1 + Date nbActivitesJour +12082022 500 +5092022 525 +7092022 740 +8092022 812 +9092022 850 +10092022 620 +11092022 601 +12092022 422 +13092022 501 diff --git a/SAE.c b/SAE.c index 832b8a0..ad76707 100644 --- a/SAE.c +++ b/SAE.c @@ -71,30 +71,47 @@ int Sauvegarde(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[ } for(i = 0; i < (nbelem-1); i++) { - fprintf(flot, "%d\t%d\t%d\t%d\t%d\t%d\t%d\n", tNoCarte[i], tage[i], tPointsCarte[i], tCarteActive[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%d\n", tDate[j], tNbActivitesJour[j]); + fprintf(jour, "%d\t\t%d\n", tDate[j], tNbActivitesJour[j]); } fclose(jour); fclose(flot); } -/* -void pointsBonus() +int ajoutPointsCarte(int tNoCarte[], int tPointsCarte[], int tCarteActive[], int nbelem) { - + int i, NoCarte, pointsCarte, CarteActive; + printf("Entrez le numero de carte de l'adherent: "); + scanf("%d", &NoCarte); + for(i = 0; i < nbelem; i++) + { + if(NoCarte == tNoCarte[i]) + { + printf("Entrez le nombre de points a ajouter: "); + scanf("%d", &pointsCarte); + tPointsCarte[i] += pointsCarte; + printf("Le nombre de points de l'adherent est maintenant de %d\n", tPointsCarte[i]); + if(tPointsCarte[i] >= 1000) + { + tCarteActive[i] = 1; + printf("La carte de l'adherent est maintenant active\n"); + } + return 0; + } + } + printf("Le numero de carte n'existe pas\n"); + return -1; } - - -int rechercheEtCreation(int tNoCarte[], int nbClients) +int rechercheEtCreation(int tNoCarte[], int nbelem) { int NoCarte, i; - for( i=0; i < nbClients; i++) + for( i=0; i < nbelem; i++) { - if(i != tNoCarte[i]) + if((i + 1) != tNoCarte[i]) { return i; } @@ -102,6 +119,52 @@ int rechercheEtCreation(int tNoCarte[], int nbClients) return i; } +int CreationAdherents(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem) +{ + int NoCarte, age, pointsCarte, CarteActive, pas; + char reponse; + printf("Donnez l'âge du client :\n"); + scanf("%d", &age); + pas = rechercheEtCreation(tNoCarte, nbelem); + for(j=nbelem; j> pas; j--) + { + tNoCarte[j] = tNoCarte[j-1]; + tage[j] = tage[j-1]; + tPointsCarte[j] = tPointsCarte[j-1]; + tCarteActive[j] = tCarteActive[j-1]; + } + tNoCarte[pas] = + tMatieres[i]= matieres; + tCoeff[i] = coeff; + nbMatieres = nbMatieres + 1; + return nbMatieres; + tNoCarte[pas] = tNoCarte[pas] + 1; + tage[pas] = age; + tPointsCarte[pas] = 0; + tCarteActive[pas] = 0; + 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') + { + printf("Entrez le nombre de points a ajouter: "); + scanf("%d", &pointsCarte); + if(pointsCarte > 0) + tPointsCarte[pas] = tPointsCarte[pas] + pointsCarte; + printf("Le nombre de points de l'adherent est maintenant de %d\nVotre carte est désormais", tPointsCarte[pas]); + } + nbelem = nbelem + 1; +} + +/* +void pointsBonus() +{ + +} + + + + + int CreationAdherents(int tAdherents[], nbClients) { int NoCarte, nom, prenom, age, pointsCarte, CarteActive, nbActivitéesJour; diff --git a/exe b/exe index 2b7b4497c3fc8f008c541385ea3c9bbd1e28c34c..5d118ea19c6fe8f4e242c1baef76390bf552a187 100755 GIT binary patch delta 835 zcmX}qUq}=|90%~7-P7Bt zMjngAHeu&jo6s{!jARu*S{U+4FRvZ+3G`F%`JCw`R3GHF(f_5-pk=ok*R2#r434=qE1 z@-Ao<>N$HJ;yz>a#Z|}x{ahP_L?}=bg)*R?%gHLv+?&k84Gc1Gf^_ilI5C5~u|C6W2#YcXuOw zsB!0-+V?|DoYZ&a^`u>wqb}R__T=-g+qreG|D*J^d_U8J1>3O;KVm=P4cc4yJKu}_ zbIL~N6~5MyE))nER*`cdHG@7%2R&|bk3RF%lX0DR-5ZFZ7y70Jgq6MDc`{DF`iF@@ rLuGE>E6|a$KctOD1E=`|dAg_kmX*)6)92Mbn~{fVXokK}JuLhMmTYTI delta 756 zcmZY6PiWI%7{~GVP5&izb={cSl}g&qfrD8b>$KoD7FIE%MP*y{Aj2Mlc(C9>)Po0Q zb`T*Tz9`eHhcN|Fa?u^!po$6}RvbFVz$%Dkh)htJx*31VOL8%!ydR#!H&4>ZGMy~b zha#0qL1JGevx!z{iek*kzTxmYheIPq5n{{C+)ObfCL^VR)_R+W9tcDFQ z9WzgETcx@5nq~Qrc~QvIje2Ic?SHorZYt48(h9 zU7dq?@1myC*pbL#pK9EktFf*~3!9602l=)yYfk+&#Ow2}79d_e|i=8pMYRj0cf;@wV&clWwV zL%f@D)eG_N07MBBqDrp)w`Hm0&%)PVRSK&9xt`gutjBmH8LOOXl(U2=$MZ(thc@8Y zkp5OF4Cz0WQAJ-bsK%aoj7Rbv8|wI1vHr%q7CrA{HGlC&d^*;yN&nqJVvmCCdHjCU zQ~awMUTy*BRh(&dCGltH?B;^X*6@Td81j2&goc1fVi+ysH_UD)Wva3#$wRbg(l&Vu z)yzcdod?ISt}g;DvXAL0sxiGs7G?!@ujemba(dqdVWrhf?!Off9!YGbKP72V)NpC$ I_x>r*KUnE3DF6Tf diff --git a/membres.don b/membres.don index 38a0d9a..01fe651 100644 --- a/membres.don +++ b/membres.don @@ -1,10 +1,10 @@ Ncarte age pointsCarte carteActive -0 0 0 0 1691030928 1691028928 1691032928 -5 5 5 5 1691030928 1691028928 1691032928 -7 7 7 7 1691030928 1691028928 1691032928 -8 8 8 8 1691030928 1691028928 1691032928 -8 8 8 8 1691030928 1691028928 1691032928 -6 6 6 6 1691030928 1691028928 1691032928 -6 6 6 6 1691030928 1691028928 1691032928 -2 2 2 2 1691030928 1691028928 1691032928 -1 1 1 1 1691030928 1691028928 1691032928 + 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 + 9 21 1 1 diff --git a/testSAE.c b/testSAE.c index 7a0e73f..68e76aa 100644 --- a/testSAE.c +++ b/testSAE.c @@ -14,8 +14,8 @@ void testOuverture(void) void testSauvegarde(void) { - int tNoCarte[500] = {0, 5, 7, 8, 8, 6, 6, 2, 1, 0}, tage[500] = {0, 5, 7, 8, 8, 6, 6, 2, 1, 0}, tPointsCarte[500] = {0, 5, 7, 8, 8, 6, 6, 2, 1, 0}, tCarteActive[500] = {0, 5, 7, 8, 8, 6, 6, 2, 1, 0}; - int tDate[500] = {0, 5, 7, 8, 8, 6, 6, 2, 1, 0}, tNbActivitesJour[500] = {0, 5, 7, 8, 8, 6, 6, 2, 1, 0}; + int tNoCarte[500] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, tage[500] = {22, 25, 47, 38, 18, 46, 36, 19, 21, 30}, tPointsCarte[500] = {10, 5, 7, 8, 8, 6, 6, 2, 1, 4}, tCarteActive[500] = {0, 1, 1, 1, 1, 1, 0, 1, 1, 1}; + int tDate[500] = {12082022, 5092022, 7092022, 8092022, 9092022, 10092022, 11092022, 12092022, 13092022, 14092022}, tNbActivitesJour[500] = {500, 525, 740, 812, 850, 620, 601, 422, 501, 520}; Sauvegarde(tNoCarte, tage, tPointsCarte, tCarteActive, tNbActivitesJour, tDate, 10); }