|
|
@ -51,17 +51,19 @@ void clientConstraint(float *weight, float *volume, float *price)
|
|
|
|
* @return an integer value.
|
|
|
|
* @return an integer value.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
// TODO réécrire cette documentation
|
|
|
|
// TODO réécrire cette documentation
|
|
|
|
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 *cagnotte, float tabWeight[], float tabVolume[], float tabPrice[], int tabItemRef[], int tabBasketRef[], int tabBasketQuantity[], int tlogItem, int tlogBasket)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
int index, found, i;
|
|
|
|
float totalWeight = 0, totalVolume = 0, totalPrice = 0, cagnotteUse;
|
|
|
|
float totalWeight = 0, totalVolume = 0, totalPrice = 0, cagnotteUse;
|
|
|
|
int i;
|
|
|
|
for (i=0; i<tlogBasket; i++)
|
|
|
|
for (i=0; i<tlog; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
totalWeight += tabWeight[i] * tabQuantity[i];
|
|
|
|
index = searchTab(tabItemRef, tabBasketRef[i], tlogItem, &found);
|
|
|
|
totalVolume += tabVolume[i] * tabQuantity[i];
|
|
|
|
if (found == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
totalWeight += tabWeight[index] * tabBasketQuantity[i];
|
|
|
|
|
|
|
|
totalVolume += tabVolume[index] * tabBasketQuantity[i];
|
|
|
|
if (*priceConstraint != -1)
|
|
|
|
if (*priceConstraint != -1)
|
|
|
|
totalPrice += tabUnitPrice[i] * tabQuantity[i];
|
|
|
|
totalPrice += tabPrice[index] * tabBasketQuantity[i];
|
|
|
|
|
|
|
|
|
|
|
|
if (totalWeight > weightConstraint)
|
|
|
|
if (totalWeight > weightConstraint)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("Attention, la contrainte de charge maximale du véhicule a été dépassée de %.2f, veuillez retirer un article\n", totalWeight - weightConstraint);
|
|
|
|
printf("Attention, la contrainte de charge maximale du véhicule a été dépassée de %.2f, veuillez retirer un article\n", totalWeight - weightConstraint);
|
|
|
@ -101,6 +103,7 @@ int constraintExceeded(float weightConstraint, float volumeConstraint, float *pr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|