From 35473f298d7ac8e9214029768eddcdd86ab3d189 Mon Sep 17 00:00:00 2001 From: Lola CHALMIN Date: Thu, 10 Nov 2022 13:32:35 +0100 Subject: [PATCH] les vrais --- sae.c | 323 ++++++++++++++++++ sae.h | 13 + saelo.c | 72 ---- saelo.h | 4 - testsaelo.c | 946 ---------------------------------------------------- tsae.c | 96 ++++++ 6 files changed, 432 insertions(+), 1022 deletions(-) create mode 100644 sae.c create mode 100644 sae.h delete mode 100644 saelo.c delete mode 100644 saelo.h delete mode 100644 testsaelo.c create mode 100644 tsae.c diff --git a/sae.c b/sae.c new file mode 100644 index 0000000..88d0f79 --- /dev/null +++ b/sae.c @@ -0,0 +1,323 @@ +#include "sae.h" +#include +#include + + +int Fillvar(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int *tacti, int *tpasseoupas, int *tptsbought, int *tptsbonus, char *tcateg, int tmax)//lis le fichier et met les valeurs dans les tableaux +{ + FILE *f; + f = fopen("donneeClient.don", "r"); + if (f == NULL) + { + printf("Problème d'ouverture du fichier Clients..."); + return -1; + } + int i = 0; + int numAd, age, state, acti, passeoupas, ptsbought, ptsbonus; + char categ, fnom[15], fprenom[15]; + + fscanf(f, "%d", &numAd); + fscanf(f, "%*c%s", fnom); + fscanf(f, "%*c%s", fprenom); + fscanf(f, "%*c%d", &age); + fscanf(f, "%*c%d", &state); + fscanf(f, "%*c%d", &acti); + fscanf(f, "%*c%d", &passeoupas); + fscanf(f, "%*c%d", &ptsbought); + fscanf(f, "%*c%d%*c", &ptsbonus); + fscanf(f, "%*c%c", &categ); + + while (!feof(f)) + { + if (i == tmax) + { + printf("Problème de gestion: trop de clients enregistrés à ce jour"); + return -1; + } + + + tAd[i] = numAd; + strcpy(tnom[i], fnom); + strcpy(tpnom[i], fprenom); + tage[i] = age; + tstate[i] = state; + tacti[i] = acti; + tpasseoupas[i] = passeoupas; + tptsbought[i] = ptsbought; + tptsbonus[i] = ptsbonus; + tcateg[i] = categ; + + i++; + + fscanf(f, "%d", &numAd); + fscanf(f, "%*c%s", fnom); + fscanf(f, "%*c%s", fprenom); + fscanf(f, "%*c%d", &age); + fscanf(f, "%*c%d", &state); + fscanf(f, "%*c%d", &acti); + fscanf(f, "%*c%d", &passeoupas); + fscanf(f, "%*c%d", &ptsbought); + fscanf(f, "%*c%d%*c", &ptsbonus); + fscanf(f, "%*c%c", &categ); + + } + fclose(f); + return 0; +} + + + +char Card(void)//demande si client a la carte +{ + char bCard; + printf("Avez-vous votre numéro de carte adhérent avec vous ?(O/N)\n"); + scanf("%c", &bCard); + return bCard; +} + + + +void Name( char *nom, char *prenom)//demande nom et prénom +{ + printf("Dans ce cas, quel est votre nom ?\n"); + scanf("%s", nom); + + printf("Et votre prénom ?\n"); + scanf("%s", prenom); +} + + + + +int FindData(char *nom, char *pnom, char tnom[][15], char tpnom[][15], int *tpasseoupas, int *tptsbought, char *action, int tmax) +{ + int i, found = 0, testnom, testpnom; + i = 0; + testnom = strcmp(tnom[i], nom);//comparer nom du fichier et nom donné + testpnom = strcmp(tpnom[i], pnom);//comparer prénom du fichier et prénom donné + while (found == 0 && i < tmax) + { + if (testnom == 0) + { + if (testpnom == 0) + found = 1; + break; + } + i++; + testnom = strcmp(tnom[i], nom); + testpnom = strcmp(tpnom[i], pnom); + } + + if (found == 0) + { + printf("Recherche non aboutie : numéro non enregistré...\n");//si le client n'est au final pas enregistré + return -1; + } + + if (found == 1)//si trouvé + { + if (tpasseoupas[i] == 1)//si client déjà passé + { + printf("Déjà passé, nombre possible de passage dans une journée : 1...\n"); + return -1; + } + printf("Carte trouvée !\n"); + return i; + } +} + + + +int FindN(int *tAd, int numAd, int *tpasseoupas, int tmax) +{ + int i, found = 0; + i = 0; + while (found == 0 && i < tmax) + { + if(tAd[i] == numAd) + { + break; + } + i++; + } + + if (found == 0) + { + printf("Recherche non aboutie : numéro non enregistré...\n");//si le client n'est au final pas enregistré + return -1; + } + + if (found == 1)//si trouvé + { + if (tpasseoupas[i] == 1)//si client déjà passé + { + printf("Déjà passé, nombre possible de passage dans une journée : 1...\n"); + return -1; + } + printf("Carte trouvée !\n"); + return i; + } +} + + +void Recharge(int *tptsbought, int place, char *tcateg) +{ + int dizpts, topay, nbpts; + printf("Combien de dizaines de points souhaitez-vous acheter ?\n"); + scanf("%d", &dizpts); + while (dizpts > 100 || dizpts < 0) + { + printf("Veuillez entrer un nombre correct de dizaines de points\n"); + scanf("%d", &dizpts); + } + + if (tcateg[place] == 'E') + { + nbpts = dizpts * 10; + topay = dizpts * 2; + tptsbought[place] += nbpts; + + printf("Vous avez désormais %d points sur la carte, vous nous devez %d\n", tptsbought[place], topay); + } + + if (tcateg[place] == 'S') + { + nbpts = dizpts * 10; + topay = dizpts * 4; + tptsbought[place] += nbpts; + + printf("Vous avez désormais %d points sur la carte, vous nous devez %d\n", tptsbought[place], topay); + } + + if (tcateg[place] == 'A') + { + nbpts = dizpts * 10; + topay = dizpts * 6; + tptsbought[place] += nbpts; + + printf("Vous avez désormais %d points sur la carte, vous nous devez %d\n", tptsbought[place], topay); + } + +} + + + +int Acti(int i) +{ + int acti; + printf("Choix de l'activité %d: badminton (1) | football (2) | zumba (3) | musculation (4) | squash (5) \n", i); + scanf("%*c%d", &acti); + while (acti != 1 && acti != 2 && acti != 3 && acti != 4 && acti != 5) + { + printf("Veuillez entrer un nombre d'activité correct (badminton (1) | football (2) | zumba (3) | musculation (4) | squash (5))\n"); + scanf("%d%*c", &acti); + } + return acti; +} + + + +int ChoiceActi(int nbacti, int *tacti) +{ + int chxacti, chx1, chx2, chx3; + + if (nbacti == 1) + { + chxacti = Acti(nbacti); + } + + + if (nbacti == 2) + { + chx1 = Acti(nbacti-1); + chx2 = Acti(nbacti); + chxacti = chx1 + chx2*10 ; + + } + else + { + chx1 = Acti(nbacti-2); + chx2 = Acti(nbacti-1); + chx3 = Acti(nbacti); + chxacti = chx1 + chx2*10 + chx3*100; + } + return chxacti; +} + + + +void ChoiceMenu(char *choix) +{ + printf("Recharge carte (R) | Afficher points (A) | Choix activités (C) | Quitter (Q)\n"); + scanf("%*c%c%*c", choix); + while (*choix != 'R' && *choix != 'A' && *choix != 'C' && *choix != 'Q') + { + printf("Entrer un caractère correct R | A | C | Q \n"); + scanf("%c%*c", choix); + } +} + + +void CheckPts(int *tptsbonus, int *tptsbought, int *tpasseoupas, int place, int acti) +{ + int u , d, c, actu, actd, actc, ptsneeded; + char confirm; + u = acti % 10;//acti1 + d = (acti-u) / 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]) + { + ("Points suffisants, confirmation ? (O/N) \n"); + scanf("%*c%c%*c", &confirm); + if (confirm == 'O') + { + tptsbought[place] -= ptsneeded; + tptsbonus[place] += ptsneeded; + if (tptsbonus[place] >= 100) + { + tptsbought[place] += 15; + tptsbonus[place] -= 100; + } + } + } + else + { + printf("J'y vais pas"); + } +} + +int CheckActi(int nb) +{ + if (nb == 1)//badminton + { + return 8; + } + + if (nb == 2)//football + { + return 5; + } + + if (nb == 3)//zumba + { + return 5; + } + + if (nb == 4)//muscu + { + return 15; + } + + if (nb == 5)//squash + { + return 10; + } +} + diff --git a/sae.h b/sae.h new file mode 100644 index 0000000..553c944 --- /dev/null +++ b/sae.h @@ -0,0 +1,13 @@ +#define TAILLE 500 + +int Fillvar(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int *tacti, int *tpasseoupas, int *tptsbought, int *tptsbonus, char *tcateg, int tmax); +char Card(void); +void Name( char *nom, char *prenom); +int FindData(char *nom, char *prenom, char tnom[][15], char tpnom[][15], int *tpasseoupas, int *tptsbought, char *action, int tmax); +void Recharge(int *tptsbought, int place, char *tcateg); +int ChoiceActi(int nbacti, int *tacti); +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 diff --git a/saelo.c b/saelo.c deleted file mode 100644 index b5e32eb..0000000 --- a/saelo.c +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#include "saelo.h" - -char Card(void)//demande si client a la carte -{ - char bCard; - printf("Avez-vous votre numéro de carte adhérent avec vous ?(O/N)\n"); - scanf("%c", &bCard); - return bCard; -} - - - -void Name( char *nom, char *prenom)//demande nom et prénom -{ - printf("Dans ce cas, quel est votre nom ?\n"); - scanf("%s%*c", nom); - printf("Et votre prénom ?\n"); - scanf("%s%*c", prenom); -} - - - -int Fillvar(FILE *f, int *numAd, char *fnom, char *fprenom, int *age, int *state, int *acti, int *passeoupas, int *ptsbought, int *ptsbonus, char *categ)//lis le fichier et met les valeurs dans les variables -{ - if (feof(f)) - { - return -1; - } - fscanf(f, "%6d\n", numAd); - fscanf(f, "%s", fnom); - fscanf(f, "%s", fprenom); - fscanf(f, "%2d", age); - fscanf(f, "%d", state); - fscanf(f, "%d", acti); - fscanf(f, "%d", passeoupas); - fscanf(f, "%2d", ptsbought); - fscanf(f, "%2d%*c", ptsbonus); - fscanf(f, "%c", categ); -} - -/* -void ifnoCard(int *testnom, int *testpnom, int *erreur, char *fnom, char *fprenom, char *nom, char *prenom, FILE *f, int numAd, int age, int state, int acti, int passeoupas, int ptsbought, int ptsbonus, char categ) -{ - - puts("Recherche de la carte !"); - - testnom = strcmp(fnom, nom);//comparer nom du fichier et nom donné - testpnom = strcmp(fprenom, prenom);//comparer prénom du fichier et prénom donné - - - - - while (testnom!=0 && testpnom!=0 && erreur != -1)// tant que les 2 différents - { - erreur = Fillvar(f, &numAd, fnom, fprenom, &age, &state, &acti, &passeoupas, &ptsbought, &ptsbonus, &categ);//rescan - - testnom = strcmp(fnom, nom);//recomparaison nom - testpnom = strcmp(fprenom, prenom);//recomparaison prénom - } - - if(erreur == -1) - { - printf("Recherche non aboutie : numéro non enregistré...\n");//si le client n'est au final pas enregistré - return; - } -} -*/ - - diff --git a/saelo.h b/saelo.h deleted file mode 100644 index c26c56b..0000000 --- a/saelo.h +++ /dev/null @@ -1,4 +0,0 @@ -void Name( char *nom, char *prenom); -char Card(void); -int Fillvar(FILE *f, int *numAd, char *fnom, char *fprenom, int *age, int *state, int *acti, int *passeoupas, int *ptsbought, int *ptsbonus, char *categ); -void ifnoCard(int *testnom, int *testpnom, int *erreur, char *fnom, char *fprenom, char *nom, char *prenom, FILE *f, int *numAd, int age, int state, int acti, int passeoupas, int ptsbought, int ptsbonus, char categ); diff --git a/testsaelo.c b/testsaelo.c deleted file mode 100644 index a9a4af7..0000000 --- a/testsaelo.c +++ /dev/null @@ -1,946 +0,0 @@ -#include -#include -#include "saelo.h" - -void main(void) -{ - char nom[15], prenom[15], fnom[15], fprenom[15], bCard, member, categ, recharge, acti1[15], acti2[15], acti3[15]; - int erreur, numAd, age, state, acti, passeoupas, ptsbought,ptsbonus, numCard, avoiravecevann, testnom, testpnom, found = 0, ptrecharge, nbacti, numacti, s1, s2, s3, m1, m2, m3, f1, f2, f3, b1, b2, b3, z1, z2, z3; - - FILE *f; - f = fopen("donneeClient.don","r"); - if (f==NULL){printf("Erreur ouverture fichier clients"); fclose(f); return;} - - - - - //accueil - printf("Bienvenue ! Déjà membre ou création de compte ? Créer (C) ou Membre (M)\n"); - scanf("%c%*c", &member); - bCard = Card(); - erreur = Fillvar(f, &numAd, fnom, fprenom, &age, &state, &acti, &passeoupas, &ptsbought, &ptsbonus, &categ); - - - - - //si nouveau client / créer nouveau compte - if (member == 'C') - { - /*creationCompte(int avoiravecevann);*/ - avoiravecevann = 2; - } - - - - - //demander nom & prénom - Name(nom, prenom); - - - //si client n'a pas son numéro de carte - if (bCard == 'N') - { - - puts("Recherche de la carte !"); - - testnom = strcmp(fnom, nom);//comparer nom du fichier et nom donné - testpnom = strcmp(fprenom, prenom);//comparer prénom du fichier et prénom donné - - - while (erreur != -1 && found == 0)// tant que pas d'erreur ou pas trouvé - { - if (testnom == 0) - { - if (testpnom == 0) - found = 1; - break; - } - - erreur = Fillvar(f, &numAd, fnom, fprenom, &age, &state, &acti, &passeoupas, &ptsbought, &ptsbonus, &categ);//rescan - testnom = strcmp(fnom, nom);//recomparaison nom - testpnom = strcmp(fprenom, prenom);//recomparaison prénom - } - - if(erreur == -1 || found == 0)//si pas trouvé ou fin de fichier - { - printf("Recherche non aboutie : numéro non enregistré...\n");//si le client n'est au final pas enregistré - return; - } - - - - if (found == 1)//si trouvé - { - if (passeoupas == 1)//si client déjà passé - { - printf("Déjà passé, nombre possible de passage dans une journée : 1...\n"); - return; - } - printf("La carte dispose de %d points, rechargement de carte souhaité ? (O/N) \n", ptsbought);//infos sur ses points + recharge ? - scanf("%c%*c", &recharge); - - - if (recharge == 'O')//si client souhaite recharger carte - { - printf("De combien de dizaine de points souhaitez vous recharger ?\n"); - scanf("%d%*c", &ptrecharge); - printf("%d", ptrecharge); - } - } - } - - - - - if (bCard == 'O')//si client a la carte - { - printf("Veuillez entrer numéro de carte ?\n"); - scanf("%d%*c", &numCard); - while (numCard < 100000 || numCard > 999999)//vérifier numéro carte correct (6 chiffres) - { - printf("Veuillez saisir un numéro de carte correct\n"); - scanf("%d%*c", &numCard); - } - - - erreur = Fillvar(f, &numAd, fnom, fprenom, &age, &state, &acti, &passeoupas, &ptsbought, &ptsbonus, &categ);//scanner le document et récupérer les variables - - while (numCard != numAd && erreur == 0)//tant que numéro de carte donné différent de celui du fichier - { - erreur = Fillvar(f, &numAd, fnom, fprenom, &age, &state, &acti, &passeoupas, &ptsbought, &ptsbonus, &categ);//rescan - } - - if (passeoupas == 1) - { - printf("Déjà passé, nombre possible de passage dans une journée : 1..."); - return; - } - - printf("La carte dispose de %d points, rechargement de carte souhaité ? (O/N) \n", ptsbought);//nombre de points qu'il a + recharger ou non - scanf("%c", &recharge); - - } - - printf("Combien d'activités souhaitées aujourd'hui ? (max 3)\n"); - scanf("%d%*c", &nbacti); - while (nbacti > 3 || nbacti <= 0) - { - printf("Nombre d'activités incorrect, veuillez re-saisir (max 3)\n"); - scanf("%d%*c", &nbacti); - } - - - //si il n'y a qu'un activité - if (nbacti == 1) - { - printf("Quelle est-elle ?(zumba/badminton/musculation/football/squash)\n"); - scanf("%s", acti1); - z1 = strcmp(acti1, "zumba"); - b1 = strcmp(acti1, "badminton"); - printf("%d", b1); - m1 = strcmp(acti1, "musculation"); - s1 = strcmp(acti1, "squash"); - f1 = strcmp(acti1, "football"); - while(z1 != 0 && b1 != 0 && m1 != 0 && s1 != 0 && f1 != 0) - { - printf("Veuillez saisir une activité correcte \n"); - scanf("%s", acti1); - } - if (z1 == 0) - { - numacti = 5; - if (ptsbought < 5) - { - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - } - ptsbought -= 5; - ptsbonus += 5; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (b1 == 0) - { - numacti = 1; - if (ptsbought < 8) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 8; - ptsbonus += 8; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (s1 == 0) - { - numacti = 4; - if (ptsbought < 10) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 10; - ptsbonus += 10; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (f1 == 0) - { - numacti = 3; - if (ptsbought < 5) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 5; - ptsbonus += 5; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (m1 == 0) - { - numacti = 2; - if (ptsbought < 15) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 15; - ptsbonus += 15; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - } - - - //si il y a 2 activités - if (nbacti == 2) - { - printf("Quelles sont-elles ?(zumba/badminton/musculation/football/squash)\n"); - scanf("%s%*c", acti1); - scanf("%s%*c", acti2); - z1 = strcmp(acti1, "zumba"); - b1 = strcmp(acti1, "badminton"); - m1 = strcmp(acti1, "musculation"); - s1 = strcmp(acti1, "squash"); - f1 = strcmp(acti1, "football"); - while(z1 != 0 && b1 != 0 && m1 != 0 && s1 != 0 && f1 != 0) - { - printf("Veuillez saisir une activité correcte \n"); - scanf("%s", acti1); - } - z2 = strcmp(acti2, "zumba"); - b2 = strcmp(acti2, "badminton"); - m2 = strcmp(acti2, "musculation"); - s2 = strcmp(acti2, "squash"); - f2 = strcmp(acti2, "football"); - while(z2 != 0 && b2 != 0 && m2 != 0 && s2 != 0 && f2 != 0) - { - printf("Veuillez saisir une activité correcte \n"); - scanf("%s", acti2); - } - - - //première activité - if (z1 == 0) - { - numacti = 5; - if (ptsbought < 5) - { - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - } - ptsbought -= 5; - ptsbonus += 5; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (b1 == 0) - { - numacti = 1; - if (ptsbought < 8) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 8; - ptsbonus += 8; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (s1 == 0) - { - numacti = 4; - if (ptsbought < 10) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 10; - ptsbonus += 10; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (f1 == 0) - { - numacti = 3; - if (ptsbought < 5) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 5; - ptsbonus += 5; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (m1 == 0) - { - numacti = 2; - if (ptsbought < 15) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 15; - ptsbonus += 15; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - - - - - //deuxième activité - if (z2 == 0) - { - numacti += 5*10; - if (ptsbought < 5) - { - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - } - ptsbought -= 5; - ptsbonus += 5; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (b2 == 0) - { - numacti += 1*10; - if (ptsbought < 8) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 8; - ptsbonus += 8; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (s2 == 0) - { - numacti += 4*10; - if (ptsbought < 10) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 10; - ptsbonus += 10; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (f2 == 0) - { - numacti += 3*10; - if (ptsbought < 5) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 5; - ptsbonus += 5; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (m2 == 0) - { - numacti += 2*10; - if (ptsbought < 15) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 15; - ptsbonus += 15; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - } - - - - - - if (nbacti == 3) - { - printf("Quelles sont-elles ?(zumba/badminton/musculation/football/squash)\n"); - scanf("%s", acti1); - scanf("%s", acti2); - scanf("%s", acti3); - z1 = strcmp(acti1, "zumba"); - b1 = strcmp(acti1, "badminton"); - m1 = strcmp(acti1, "musculation"); - s1 = strcmp(acti1, "squash"); - f1 = strcmp(acti1, "football"); - while(z1 != 0 && b1 != 0 && m1 != 0 && s1 != 0 && f1 != 0) - { - printf("Veuillez saisir une activité correcte \n"); - scanf("%s", acti1); - } - z2 = strcmp(acti2, "zumba"); - b2 = strcmp(acti2, "badminton"); - m2 = strcmp(acti2, "musculation"); - s2 = strcmp(acti2, "squash"); - f2 = strcmp(acti2, "football"); - while(z2 != 0 && b2 != 0 && m2 != 0 && s2 != 0 && f2 != 0) - { - printf("Veuillez saisir une activité correcte \n"); - scanf("%s", acti2); - } - z3 = strcmp(acti3, "zumba"); - b3 = strcmp(acti3, "badminton"); - m3 = strcmp(acti3, "musculation"); - s3 = strcmp(acti3, "squash"); - f3 = strcmp(acti3, "football"); - while(z3 != 0 && b3 != 0 && m3 != 0 && s3 != 0 && f3 != 0) - { - printf("Veuillez saisir une activité correcte \n"); - scanf("%s", acti3); - } - - //première activité - if (z1 == 0) - { - numacti = 5; - if (ptsbought < 5) - { - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - } - ptsbought -= 5; - ptsbonus += 5; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (b1 == 0) - { - numacti = 1; - if (ptsbought < 8) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 8; - ptsbonus += 8; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (s1 == 0) - { - numacti = 4; - if (ptsbought < 10) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 10; - ptsbonus += 10; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (f1 == 0) - { - numacti = 3; - if (ptsbought < 5) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 5; - ptsbonus += 5; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (m1 == 0) - { - numacti = 2; - if (ptsbought < 15) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 15; - ptsbonus += 15; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - - - - printf("%d", numacti); - //deuxième activité - if (z2 == 0) - { - numacti += 5*10; - if (ptsbought < 5) - { - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - } - ptsbought -= 5; - ptsbonus += 5; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (b2 == 0) - { - numacti += 1*10; - if (ptsbought < 8) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 8; - ptsbonus += 8; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (s2 == 0) - { - numacti += 4*10; - if (ptsbought < 10) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 10; - ptsbonus += 10; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (f2 == 0) - { - numacti += 3*10; - if (ptsbought < 5) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 5; - ptsbonus += 5; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (m2 == 0) - { - numacti += 2*10; - if (ptsbought < 15) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 15; - ptsbonus += 15; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - - printf("%d", numacti); - //troisième activité - if (z3 == 0) - { - numacti += 5*100; - if (ptsbought < 5) - { - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - } - ptsbought -= 5; - ptsbonus += 5; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (b3 == 0) - { - numacti += 1*100; - if (ptsbought < 8) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 8; - ptsbonus += 8; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (s3 == 0) - { - numacti += 4*100; - if (ptsbought < 10) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 10; - ptsbonus += 10; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (f3 == 0) - { - numacti += 3*100; - if (ptsbought < 5) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 5; - ptsbonus += 5; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - if (m3 == 0) - { - numacti += 2*100; - if (ptsbought < 15) - printf("Pas assez de points disponibles sur la carte, rechargement souhaité ? (O/N)\n"); - scanf("%c%*c", &recharge); - if (recharge == 'N') - { - return; - } - else - { - //RELOAD AND CONTINUE - return; - } - ptsbought -= 15; - ptsbonus += 15; - if (ptsbonus >= 100) - { - ptsbought += 15; - ptsbonus -= 100; - } - } - } - - - printf("%d", numacti); - - return; -} diff --git a/tsae.c b/tsae.c new file mode 100644 index 0000000..a1fa928 --- /dev/null +++ b/tsae.c @@ -0,0 +1,96 @@ +#include "sae.h" +#include +#include + +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; + Fillvar(tAd, tnom, tpnom, tage, tstate, tacti, tpasseoupas, tptsbought, tptsbonus, tcateg, 500); + + printf("Bienvenue ! \nMembre (M) | Création compte (C)\n"); + scanf("%c%*c", &member); + while (member != 'M' && member != 'C') + { + 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 + + if (member == 'C')//si il y a besoin de créer un compte + { + //à voir avec evann + return; + } + + if (member == 'M')//si le client est déjà membre + { + if (bCard == 'N')// si client n'a pas la carte + { + Name(nom, pnom); + + puts("Recherche de la carte !"); + + place = FindData(nom, pnom, tnom, tpnom, tpasseoupas, tptsbought, &action, 500); + if (place == -1) + { + return; + } + } + + if (bCard == 'O') + { + printf("Numéro carte : \t"); + scanf("%*c%d", &numAd); + ret = FindN(tAd, numAd, tpasseoupas, 500); + if (ret == -1) + { + main(); + } + } + + ChoiceMenu(&choix); + + if (choix == 'A') + { + printf("La carte dispose de %d points.\n", tptsbought[place]);//infos sur ses points + ChoiceMenu(&choix); + } + + if (choix == 'R') + { + Recharge(tptsbought, place, tcateg); + ChoiceMenu(&choix); + } + + if (choix == 'C') + { + printf("Nombre d'activités souhaitées ? (max 3)\n"); + scanf("%d", &nbacti); + while (nbacti < 0 || nbacti > 3) + { + printf("Nombre d'activités incorrect (max 3)\n"); + scanf("%d", &nbacti); + } + + chxacti = ChoiceActi(nbacti, tacti); + CheckPts(tptsbonus, tptsbought, tpasseoupas, place, chxacti); + + + tacti[place] = chxacti; + + ChoiceMenu(&choix); + + } + + if (choix == 'Q') + { + //menuglobal() + return; + } + + } + + }