From 1e52748f79a9a4b23d02af3eabc64494a5b45ba3 Mon Sep 17 00:00:00 2001 From: Lola CHALMIN Date: Thu, 10 Nov 2022 14:30:36 +0100 Subject: [PATCH] new version --- sae.c | 17 ++++++++++------- sae.h | 2 +- tsae.c | 29 +++++++++++++++++++---------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/sae.c b/sae.c index 88d0f79..28c4f54 100644 --- a/sae.c +++ b/sae.c @@ -234,7 +234,8 @@ int ChoiceActi(int nbacti, int *tacti) chxacti = chx1 + chx2*10 ; } - else + + if (nbacti == 3) { chx1 = Acti(nbacti-2); chx2 = Acti(nbacti-1); @@ -258,19 +259,18 @@ void ChoiceMenu(char *choix) } -void CheckPts(int *tptsbonus, int *tptsbought, int *tpasseoupas, int place, int acti) +void CheckPts(int *tptsbonus, int *tptsbought, int *tpasseoupas, int *tacti, char *tcateg, int place, int acti, int *insuf) { - int u , d, c, actu, actd, actc, ptsneeded; + printf("%d\n", acti); + int u , d, c, actu = 0, actd = 0, actc = 0, ptsneeded; char confirm; u = acti % 10;//acti1 - d = (acti-u) / 10 ;//acti2 + d = (acti % 100 )/10 ;//acti2 c = acti / 100;//acti3 actu = CheckActi(u); - printf actd = CheckActi(d); actc = CheckActi(c); ptsneeded = actu + actd + actc; - printf("%d", ptsneeded); if (ptsneeded <= tptsbought[place]) { @@ -285,14 +285,17 @@ void CheckPts(int *tptsbonus, int *tptsbought, int *tpasseoupas, int place, int tptsbought[place] += 15; tptsbonus[place] -= 100; } + + tacti[place] = acti; } } else { - printf("J'y vais pas"); + *insuf = 1; } } + int CheckActi(int nb) { if (nb == 1)//badminton diff --git a/sae.h b/sae.h index 553c944..c7092c7 100644 --- a/sae.h +++ b/sae.h @@ -10,4 +10,4 @@ int Acti(int i); void ChoiceMenu(char *choix); int CheckActi(int nb); int FindN(int *tAd, int numAd, int *tpasseoupas, int tmax); -void CheckPts(int *tptsbonus, int *tptsbought, int *tpasseoupas, int place, int acti); \ No newline at end of file +void CheckPts(int *tptsbonus, int *tptsbought, int *tpasseoupas, int *tacti, char *tcateg, int place, int acti, int *insuf); \ No newline at end of file diff --git a/tsae.c b/tsae.c index a1fa928..6bb0aa3 100644 --- a/tsae.c +++ b/tsae.c @@ -4,8 +4,8 @@ void main(void) { - int tAd[TAILLE], tage[TAILLE], tstate[TAILLE], tacti[TAILLE], tpasseoupas[TAILLE], tptsbought[TAILLE], tptsbonus[TAILLE], place, nbacti, chxacti, numAd, ret; - char tcateg[TAILLE], nom[TAILLE], pnom[TAILLE], fnom[TAILLE], fpnom[TAILLE], bCard, member, tnom[TAILLE][15], tpnom[TAILLE][15], action, choix; + int tAd[TAILLE], tage[TAILLE], tstate[TAILLE], tacti[TAILLE], tpasseoupas[TAILLE], tptsbought[TAILLE], tptsbonus[TAILLE], place, nbacti, chxacti, numAd, ret, insuf; + char tcateg[TAILLE], nom[TAILLE], pnom[TAILLE], fnom[TAILLE], fpnom[TAILLE], bCard, member, tnom[TAILLE][15], tpnom[TAILLE][15], action, choix, recharge; Fillvar(tAd, tnom, tpnom, tage, tstate, tacti, tpasseoupas, tptsbought, tptsbonus, tcateg, 500); printf("Bienvenue ! \nMembre (M) | Création compte (C)\n"); @@ -15,7 +15,7 @@ void main(void) printf("Saisir un caractère correct (Membre M ou Création C)\n"); scanf("%*c%c%*c", &member); } - + bCard = Card();//demande si carte avec client ou non @@ -76,21 +76,30 @@ void main(void) } chxacti = ChoiceActi(nbacti, tacti); - CheckPts(tptsbonus, tptsbought, tpasseoupas, place, chxacti); - + CheckPts(tptsbonus, tptsbought, tpasseoupas, tacti, tcateg, place, chxacti, &insuf); + if (insuf == 1) + { + printf("Nombre de points insuffisants : Recharge (R) ou Quitter (Q)"); + scanf("%*c%c%*c", &recharge); + if (recharge == 'R') + { + Recharge(tptsbought, place, tcateg); + } + else + { + ChoiceMenu(&choix); + } + } - tacti[place] = chxacti; ChoiceMenu(&choix); - } + } if (choix == 'Q') { //menuglobal() return; } - } - - } +}