diff --git a/FonctionsClient.c b/FonctionsClient.c index 71aea9d..7668394 100644 --- a/FonctionsClient.c +++ b/FonctionsClient.c @@ -10,9 +10,17 @@ *\date 20 oct 2023 */ -float initVoiture(float *chargeV) +float initClient(float *chargeV,int *codeC) { + int tmax=100; + int tabNC [100]={0}, tabsuspension [100]={0}; + float tabCAG [100]={0}; + tableaucharge(tabNC,tabCAG,tabsuspension,tmax); +/*vazy je finis demain ça clc*/ float volV; + printf("Quel est votre code client ? : "); + scanf("%f",codeC); + printf("Quel est le volume (L) du coffre de votre véhicule : "); scanf("%f",&volV); while (volV < 0) diff --git a/FonctionsClient.h b/FonctionsClient.h index 71836c9..4f48305 100644 --- a/FonctionsClient.h +++ b/FonctionsClient.h @@ -9,11 +9,12 @@ /** -*\brief Demande a l'utilisateur la charge et le volume de son véhicule et les renvoie. -*\param[in,out] chargeV flottant, la charge totale du véhicule du client (en kg). +*\brief Demande a l'utilisateur son code client ainsi que la charge et le volume de son véhicule. +*\param[in,out] chargeV pointeur vers flottant, la charge totale du véhicule du client (en kg). +*\param[in,out] codeC pointeur vers entier, le code qui permet d'identifier le client. *\return flottant, le volume (en L) du coffre du véhicule du client. */ -float initVoiture(float *chargeV); +float initClient(float *chargeV, int *codeC); /** *\brief Demande un article a l'utilisateur puis l'ajoute au panier. diff --git a/FonctionsResponsable.c b/FonctionsResponsable.c index faf46d9..d9b368f 100644 --- a/FonctionsResponsable.c +++ b/FonctionsResponsable.c @@ -9,29 +9,24 @@ *\date 11 oct 2023 */ -void AjoutArticle(void) +int AjoutArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n) { - int ref; + int ref,pos; float poid,volume,prix; - FILE *flot; - flot = fopen("articles.don","a"); - if (flot == NULL) - { - printf("Problème avec la création du fichier\n"); - exit(1); - } printf("Saisir la référence de l'article (-1 pour arrêter): "); scanf("%d",&ref); - /*Si l'article existe déja, code d'erreur*/ - - /*Passer par table au lieu de fichier pour ajoutarticle*/ - /*demander numéro client et regarder cagnotte*/ while (ref < -1) { printf("Erreur ; Le numéro doit être positif (ou -1 pour arrêter); retapez : "); scanf("%d",&ref); } + pos = posRef(Tref,ref,n); + if (pos >= 0) + { + printf("L'article fait déja partie de la base de donnée."); + return n; + } while (ref >= 0) { printf("Saisir le poid(kg): "); @@ -58,7 +53,10 @@ void AjoutArticle(void) scanf("%f",&prix); } - fprintf(flot,"%d\t%.3f\t%.2f\t%.2f\n",ref,poid,volume,prix); + Tref[n] = ref; + Tpoid[n] = poid; + Tvolume[n] = volume; + Tprix[n] = prix; printf("Saisir la référence de l'article (-1 pour arrêter): "); scanf("%d",&ref); while (ref < -1) @@ -67,8 +65,8 @@ void AjoutArticle(void) scanf("%d",&ref); } } - fclose(flot); printf("Fin de l'ajout.\n"); + return n+1; } int TableArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[]) diff --git a/FonctionsResponsable.h b/FonctionsResponsable.h index be898ed..135cea2 100644 --- a/FonctionsResponsable.h +++ b/FonctionsResponsable.h @@ -12,7 +12,7 @@ *\param void Rien *\return Rien */ -void AjoutArticle(void); +int AjoutArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n); /** *\brief Demande un article au responsable puis modifie son poid, son volume et son prix dans les tables. diff --git a/Globale.c b/Globale.c index 27b3419..71d79df 100644 --- a/Globale.c +++ b/Globale.c @@ -16,7 +16,7 @@ */ void global(void) { - int n=0,rep; + int n=0,rep,codeC; int Tref[100]={0}; float Tpoid[100]={0},Tvolume[100]={0},Tprix[100]={0},volV,chargeV;; n = TableArticle(Tref,Tpoid,Tvolume,Tprix); @@ -45,7 +45,7 @@ void global(void) scanf("%d",&rep); while (rep != 9) { - while ((rep < 0 || rep > 3) && rep != 9) + while ((rep < 0 || rep > 4) && rep != 9) { printf("Erreur; (afficher[0]/afficher article[1]/ajouter[2]/modifier[3]/supprimer[4]/quitter[9]) "); scanf("%d",&rep); @@ -62,8 +62,7 @@ void global(void) } if (rep == 2) { - AjoutArticle(); - n = TableArticle(Tref,Tpoid,Tvolume,Tprix); + n = AjoutArticle(Tref,Tpoid,Tvolume,Tprix,n); printf("\n"); } if (rep == 3) @@ -98,7 +97,10 @@ void global(void) if (rep == 1) { printf("Bienvenue Mr. le client :)\n"); - volV = initVoiture(&chargeV); + printf("Voici la liste des articles disponibles : "); + AffichTable(Tref,Tpoid,Tvolume,Tprix,n); + printf("\n"); + volV = initClient(&chargeV,&codeC); printf("Que voulez vous faire ? (Ajout[0]/ModifierArticle[1]/SupprimerArticle[2]/AfficherPanier[3]/ResetPanier[4]/quitter[9]) "); scanf("%d",&rep); int TrefC[200]={0},TquanC[200]={0},nArticle=0; @@ -118,11 +120,13 @@ void global(void) if (rep == 1) { ModifArticlePanier(TrefC,TquanC,nArticle,Tref,n); + affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n); printf("\n"); } if (rep == 2) { nArticle = SupprArticlePanier(TrefC,TquanC,nArticle,Tref,n); + affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n); printf("\n"); } if (rep == 3)