master
Lola CHALMIN 2 years ago
parent 2924fbae0f
commit 86f2d9d8bf

109
sae.c

@ -16,16 +16,16 @@ int Fillvar(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate,
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);
fscanf(f, "%d%*c", &numAd);
fscanf(f, "%s%*c", fnom);
fscanf(f, "%s%*c", fprenom);
fscanf(f, "%d%*c", &age);
fscanf(f, "%d%*c", &state);
fscanf(f, "%d%*c", &acti);
fscanf(f, "%d%*c", &passeoupas);
fscanf(f, "%d%*c", &ptsbought);
fscanf(f, "%d%*c", &ptsbonus);
fscanf(f, "%c%*c", &categ);
while (!feof(f))
{
@ -49,18 +49,19 @@ int Fillvar(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate,
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);
fscanf(f, "%d%*c", &numAd);
fscanf(f, "%s%*c", fnom);
fscanf(f, "%s%*c", fprenom);
fscanf(f, "%d%*c", &age);
fscanf(f, "%d%*c", &state);
fscanf(f, "%d%*c", &acti);
fscanf(f, "%d%*c", &passeoupas);
fscanf(f, "%d%*c", &ptsbought);
fscanf(f, "%d%*c", &ptsbonus);
fscanf(f, "%c%*c", &categ);
}
fclose(f);
return i;
}
@ -164,12 +165,7 @@ 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);
}
scanf("%d%*c", &dizpts);
if (tcateg[place] == 'E')
{
@ -247,15 +243,17 @@ int ChoiceActi(int nbacti, int *tacti)
void ChoiceMenu(char *choix)
int ChoiceMenu(void)
{
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')
int choix;
printf("Recharge carte (1) | Afficher points (2) | Choix activités (3) | Quitter (4)\n");
scanf("%d", &choix);
while (choix > 4 || choix < 1)
{
printf("Entrer un caractère correct R | A | C | Q \n");
scanf("%c%*c%*c", choix);
printf("Entrer un caractère correct 1 | 2 | 3 | 4 \n");
scanf("%d%*c", &choix);
}
return choix;
}
@ -364,4 +362,51 @@ void Save(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, i
}
void Loop(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int *tacti, int *tpasseoupas, int *tptsbought, int *tptsbonus, char *tcateg, int *choix, int *insuf, int place, int nbacti)
{
int chxacti;
char recharge;
while (*choix != 4)
{
if (*choix == 2)
{
printf("La carte dispose de %d points.\n", tptsbought[place]);//infos sur ses points
}
if (*choix == 1)
{
Recharge(tptsbought, place, tcateg);
}
if (*choix == 3)
{
printf("Nombre d'activités souhaitées ? (max 3)\n");
scanf("%*c%d", &nbacti);
while (nbacti < 0 || nbacti > 3)
{
printf("Nombre d'activités incorrect (max 3)\n");
scanf("%*c%d", &nbacti);
}
chxacti = ChoiceActi(nbacti, tacti);
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);
}
}
}
*choix = ChoiceMenu();
}
}

@ -7,8 +7,9 @@ int FindData(char *nom, char *prenom, char tnom[][15], char tpnom[][15], int *tp
void Recharge(int *tptsbought, int place, char *tcateg);
int ChoiceActi(int nbacti, int *tacti);
int Acti(int i);
void ChoiceMenu(char *choix);
int ChoiceMenu(void);
int CheckActi(int nb);
int FindN(int *tAd, int numAd, int *tpasseoupas, int tmax);
void CheckPts(int *tptsbonus, int *tptsbought, int *tpasseoupas, int *tacti, char *tcateg, int place, int acti, int *insuf);
void Save(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int *tacti, int *tpasseoupas, int *tptsbought, int *tptsbonus, char *tcateg, int tmax, int place);
void Save(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int *tacti, int *tpasseoupas, int *tptsbought, int *tptsbonus, char *tcateg, int tmax, int place);
void Loop(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int *tacti, int *tpasseoupas, int *tptsbought, int *tptsbonus, char *tcateg, int *choix, int *insuf, int place, int nbacti);

@ -4,29 +4,12 @@
void main(void)
{
int tAd[TAILLE], tage[TAILLE], tstate[TAILLE], tacti[TAILLE], tpasseoupas[TAILLE], tptsbought[TAILLE], tptsbonus[TAILLE], place, nbacti, chxacti, numAd, ret, insuf, day = 0;
char tcateg[TAILLE], nom[TAILLE], pnom[TAILLE], fnom[TAILLE], fpnom[TAILLE], bCard, member, tnom[TAILLE][15], tpnom[TAILLE][15], action, choix, recharge;
int tAd[TAILLE], tage[TAILLE], tstate[TAILLE], tacti[TAILLE], tpasseoupas[TAILLE], tptsbought[TAILLE], tptsbonus[TAILLE], place, nbacti, choix, chxacti, numAd, ret, insuf, day = 0;
char tcateg[TAILLE], nom[TAILLE], pnom[TAILLE], fnom[TAILLE], fpnom[TAILLE], bCard, tnom[TAILLE][15], tpnom[TAILLE][15], action, recharge;
place = 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);
@ -51,56 +34,21 @@ void main(void)
}
}
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, 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);
}
}
ChoiceMenu(&choix);
choix = ChoiceMenu();
Loop(tAd, tnom, tpnom, tage, tstate, tacti, tpasseoupas, tptsbought, tptsbonus, tcateg, &choix, &insuf, place, nbacti);
}
if (choix == 'Q')
if (choix == 4)
{
//menuglobal()
return;
}
}
/*while (choix != 4)
{
choix =ChoiceMenu();
}*/
}

Loading…
Cancel
Save