ajout des dernières modifications

master
Ange BARDET 1 year ago
parent 0479238d93
commit 2fc710b292

@ -10,16 +10,29 @@
*\date 20 oct 2023 *\date 20 oct 2023
*/ */
float initClient(float *chargeV,int *codeC) float initClient(float *chargeV,int *codeC, float *cagnotte)
{ {
int tmax=100; int tmax=100,n,pos;
int tabNC [100]={0}, tabsuspension [100]={0}; int tabNC [100]={0}, tabsuspension [100]={0};
float tabCAG [100]={0}; float tabCAG [100]={0};
tableaucharge(tabNC,tabCAG,tabsuspension,tmax); n = tableaucharge(tabNC,tabCAG,tabsuspension,tmax)+1;
/*vazy je finis demain ça clc*/
float volV; float volV;
printf("Quel est votre code client ? : "); printf("Quel est votre code client ? : ");
scanf("%f",codeC); scanf("%d",codeC);
pos = posRef(tabNC,*codeC,n);
if (pos >= 0)
{
printf("Votre cagnotte actuelle est de %.2f\n",tabCAG[pos]);
*cagnotte = tabCAG[pos];
}
if (pos >= 0 && tabsuspension[pos] == 1)
{
printf("La carte est suspendu, vous n'avez pas accès a votre cagnotte.\n");
}
if (pos < 0)
{
printf("Vous n'êtes pas encore référencée dans les clients.\n");
}
printf("Quel est le volume (L) du coffre de votre véhicule : "); printf("Quel est le volume (L) du coffre de votre véhicule : ");
scanf("%f",&volV); scanf("%f",&volV);
@ -74,12 +87,12 @@ int ajoutPanier(int TrefC[],int TquanC[],int nArticle,int Tref[], int n)
return nArticle +=1; return nArticle +=1;
} }
void affichPanier(int TrefC[],int TquanC[],int nArticle,int Tref[], float Tpoid[],float Tvolume[],float Tprix[],float chargeV, float volV,int n) void affichPanier(int TrefC[],int TquanC[],int nArticle,int Tref[], float Tpoid[],float Tvolume[],float Tprix[],float chargeV, float volV,int n, float cagnotteC)
{ {
printf("\nRéf\tQté\tPoids\tVol\tPrixU\tPoidsTot\tVolTot\tPrixTot\tCagnotte\n"); printf("\nRéf\tQté\tPoids\tVol\tPrixU\tPoidsTot\tVolTot\tPrixTot\tCagnotte\n");
int i, pos,cagnotte; int i, pos;
float prixtot,volR,chargeR; float prixtot,volR,chargeR,cagnotte;
int cfinal=0; float cfinal=0;
float prixfinal=0,volfinal=0,chargefinal=0; float prixfinal=0,volfinal=0,chargefinal=0;
for (i=0;i <nArticle;i++) for (i=0;i <nArticle;i++)
{ {
@ -90,10 +103,10 @@ void affichPanier(int TrefC[],int TquanC[],int nArticle,int Tref[], float Tpoid[
cfinal+=cagnotte; cfinal+=cagnotte;
volfinal+=Tvolume[pos]*TquanC[i]; volfinal+=Tvolume[pos]*TquanC[i];
chargefinal+=Tpoid[pos]*TquanC[i]; chargefinal+=Tpoid[pos]*TquanC[i];
printf("%d\t%d\t%.1f\t%.1f\t%.1f\t%.1f\t\t%.1f\t%.1f\t%d\n",TrefC[i],TquanC[i],Tpoid[pos],Tvolume[pos],Tprix[pos],Tpoid[pos]*TquanC[i],Tvolume[pos]*TquanC[i],prixtot,cagnotte); printf("%d\t%d\t%.1f\t%.1f\t%.1f\t%.1f\t\t%.1f\t%.1f\t%.2f\n",TrefC[i],TquanC[i],Tpoid[pos],Tvolume[pos],Tprix[pos],Tpoid[pos]*TquanC[i],Tvolume[pos]*TquanC[i],prixtot,cagnotte);
} }
printf("\n\t\t\t\t\t\tPrix total à payer:\t%.0f euros\n",prixfinal); printf("\n\t\t\t\t\t\tPrix total à payer:\t%.0f euros\n",prixfinal);
printf("\t\t\t\t\t\tCagnotte totale:\t%d euros\n",cfinal); printf("\t\t\t\t\t\tCagnotte totale:\t%.2f euros\n",cfinal+cagnotteC);
volR = volV - volfinal; volR = volV - volfinal;
printf("Volume utilisé: %.0f litres\n",volfinal); printf("Volume utilisé: %.0f litres\n",volfinal);

@ -9,12 +9,12 @@
/** /**
*\brief Demande a l'utilisateur son code client ainsi que la charge et le volume de son véhicule. *\brief Demande a l'utilisateur son code client ainsi que la charge et le volume de son véhicule. La fonction charge également la cagnotte du client.
*\param[in,out] chargeV pointeur vers flottant, la charge totale du véhicule du client (en kg). *\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. *\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. *\return flottant, le volume (en L) du coffre du véhicule du client.
*/ */
float initClient(float *chargeV, int *codeC); float initClient(float *chargeV, int *codeC, float *cagnotte);
/** /**
*\brief Demande un article a l'utilisateur puis l'ajoute au panier. *\brief Demande un article a l'utilisateur puis l'ajoute au panier.
@ -41,7 +41,7 @@ int ajoutPanier(int TrefC[],int TquanC[],int nArticle,int Tref[], int n);
*\param[in] n entier, taille logique des tableaux concernant les produits. *\param[in] n entier, taille logique des tableaux concernant les produits.
*\return Rien *\return Rien
*/ */
void affichPanier(int TrefC[],int TquanC[],int nArticle,int Tref[],float Tpoid[],float Tvolume[],float Tprix[],float chargeV, float volV,int n); void affichPanier(int TrefC[],int TquanC[],int nArticle,int Tref[],float Tpoid[],float Tvolume[],float Tprix[],float chargeV, float volV,int n, float cagnotteC);
/** /**
*\brief Demande un article au client puis le modifie sa quantité. *\brief Demande un article au client puis le modifie sa quantité.

@ -18,7 +18,7 @@ void global(void)
{ {
int n=0,rep,codeC; int n=0,rep,codeC;
int Tref[100]={0}; int Tref[100]={0};
float Tpoid[100]={0},Tvolume[100]={0},Tprix[100]={0},volV,chargeV;; float Tpoid[100]={0},Tvolume[100]={0},Tprix[100]={0},volV,chargeV,cagnotteC;
n = TableArticle(Tref,Tpoid,Tvolume,Tprix); n = TableArticle(Tref,Tpoid,Tvolume,Tprix);
printf("Responsable / Client ? (R[0]/C[1])"); printf("Responsable / Client ? (R[0]/C[1])");
scanf("%d",&rep); scanf("%d",&rep);
@ -97,10 +97,10 @@ void global(void)
if (rep == 1) if (rep == 1)
{ {
printf("Bienvenue Mr. le client :)\n"); printf("Bienvenue Mr. le client :)\n");
printf("Voici la liste des articles disponibles : "); printf("Voici la liste des articles disponibles : \n");
AffichTable(Tref,Tpoid,Tvolume,Tprix,n); AffichTable(Tref,Tpoid,Tvolume,Tprix,n);
printf("\n"); printf("\n");
volV = initClient(&chargeV,&codeC); volV = initClient(&chargeV,&codeC,&cagnotteC);
printf("Que voulez vous faire ? (Ajout[0]/ModifierArticle[1]/SupprimerArticle[2]/AfficherPanier[3]/ResetPanier[4]/quitter[9]) "); printf("Que voulez vous faire ? (Ajout[0]/ModifierArticle[1]/SupprimerArticle[2]/AfficherPanier[3]/ResetPanier[4]/quitter[9]) ");
scanf("%d",&rep); scanf("%d",&rep);
int TrefC[200]={0},TquanC[200]={0},nArticle=0; int TrefC[200]={0},TquanC[200]={0},nArticle=0;
@ -114,24 +114,24 @@ void global(void)
if (rep == 0) if (rep == 0)
{ {
nArticle = ajoutPanier(TrefC,TquanC,nArticle,Tref,n); nArticle = ajoutPanier(TrefC,TquanC,nArticle,Tref,n);
affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n); affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n,cagnotteC);
printf("\n"); printf("\n");
} }
if (rep == 1) if (rep == 1)
{ {
ModifArticlePanier(TrefC,TquanC,nArticle,Tref,n); ModifArticlePanier(TrefC,TquanC,nArticle,Tref,n);
affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n); affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n,cagnotteC);
printf("\n"); printf("\n");
} }
if (rep == 2) if (rep == 2)
{ {
nArticle = SupprArticlePanier(TrefC,TquanC,nArticle,Tref,n); nArticle = SupprArticlePanier(TrefC,TquanC,nArticle,Tref,n);
affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n); affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n,cagnotteC);
printf("\n"); printf("\n");
} }
if (rep == 3) if (rep == 3)
{ {
affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n); affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n,cagnotteC);
printf("\n"); printf("\n");
} }
if (rep == 4) if (rep == 4)

@ -1,5 +1,6 @@
344 0.00 0 344 12.00 0
12 0.00 0 12 783.00 0
42 0.00 0 42 0.00 0
414 0.00 0 414 49.00 0
142 0.00 1 142 5.00 1

Loading…
Cancel
Save