From 658e1d2469a2f45fe81cfa9dcb170c1e3ee1a69f Mon Sep 17 00:00:00 2001 From: "louis.germain" Date: Mon, 23 Oct 2023 09:55:20 +0200 Subject: [PATCH] Correction de bugs --- src/main.h | 2 +- src/panier.c | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main.h b/src/main.h index 7478548..35fcbbf 100644 --- a/src/main.h +++ b/src/main.h @@ -38,4 +38,4 @@ int recherche(int val, int tab[], int tlog); //! PANIER void clientConstraint(float *weight, float *volume, float *price); -int constraintExceeded(float weightConstraint, float volumeConstraint, float priceConstraint, float tabWeight, float tabVolume, float tabUnitPrice, int tabQuantity, int tlog, float *cagnotte); \ No newline at end of file +int constraintExceeded(float weightConstraint, float volumeConstraint, float *priceConstraint, float tabWeight[], float tabVolume[], float tabUnitPrice[], int tabQuantity[], int tlog, float *cagnotte); \ No newline at end of file diff --git a/src/panier.c b/src/panier.c index 0c9d439..cb5785e 100644 --- a/src/panier.c +++ b/src/panier.c @@ -30,16 +30,16 @@ void clientConstraint(float *weight, float *volume, float *price) } } -int constraintExceeded(float weightConstraint, float volumeConstraint, float priceConstraint, float tabWeight, float tabVolume, float tabUnitPrice, int tabQuantity, int tlog, float *cagnotte) +int constraintExceeded(float weightConstraint, float volumeConstraint, float *priceConstraint, float tabWeight[], float tabVolume[], float tabUnitPrice[], int tabQuantity[], int tlog, float *cagnotte) { float totalWeight = 0, totalVolume = 0, totalPrice = 0, cagnotteUse; int i; for (i=0; i weightConstraint) { @@ -51,34 +51,34 @@ int constraintExceeded(float weightConstraint, float volumeConstraint, float pri printf("Attention, la contrainte de volume maximum a été dépassé de %.2f, veuillez retirer un article\n", totalVolume - volumeConstraint); return -1; } - if (priceConstraint != -1 && totalPrice > priceConstraint) + if (*priceConstraint != -1 && totalPrice > *priceConstraint) { - printf("Attention, la contrainte de budget maximum a été dépassé de %.2f\n", totalPrice - priceConstraint); - if (cagnotte < totalPrice) + printf("Attention, la contrainte de budget maximum a été dépassé de %.2f\n", totalPrice - *priceConstraint); + if (*cagnotte < totalPrice) { printf("Le prix total excédant votre cagnotte, veuillez retirer un article\n"); return -1; } else { - printf("Vous pouvez utiliser votre cagnotte, dont le montant est de %.2f, entrez le montant à utiliser ou -1 si vous voulez retirer un article: ", cagnotte); - scanf(%f, &cagnotteUse); + printf("Vous pouvez utiliser votre cagnotte, dont le montant est de %.2f, entrez le montant à utiliser ou -1 si vous voulez retirer un article: ", *cagnotte); + scanf("%f", &cagnotteUse); if (cagnotteUse == -1) return -1; - while (cagnotteUse > cagnotte || totalPrice-cagnotteUse < priceConstraint) + while (cagnotteUse > *cagnotte || totalPrice-cagnotteUse > *priceConstraint) { - if (cagnotteUse > cagnotte) + if (cagnotteUse > *cagnotte) printf("Erreur: vous ne pouvez pas utiliser plus que vous n'avez, réessayez ou entrer -1 si vous souhaitez retirer un article: "); - if (totalPrice-cagnotteUse < priceConstraint) - printf("Erreur: vous n'avez pas utilisé assez de votre cagnotte, vous devez utiliser au moins %.2f, veuillez rentrer le montant à utiliser ou -1 si vous voulez retirer un article: ", totalPrice - priceConstraint); + if (totalPrice-cagnotteUse > *priceConstraint) + printf("Erreur: vous n'avez pas utilisé assez de votre cagnotte, vous devez utiliser au moins %.2f, veuillez rentrer le montant à utiliser ou -1 si vous voulez retirer un article: ", totalPrice - *priceConstraint); scanf("%f", &cagnotteUse); if (cagnotteUse == -1) return -1; *cagnotte -= cagnotteUse; - priceConstraint += cagnotteUse; + *priceConstraint += cagnotteUse; } } } } - return 0 + return 0; } \ No newline at end of file