|
|
|
@ -30,6 +30,27 @@ void clientConstraint(float *weight, float *volume, float *price)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The function checks if the weight, volume, and price constraints are exceeded and allows the user to
|
|
|
|
|
* use their cagnotte (a type of credit) to stay within the price constraint.
|
|
|
|
|
*
|
|
|
|
|
* @param weightConstraint The weight constraint for the vehicle `float`.
|
|
|
|
|
* @param volumeConstraint The volume constraint is the maximum volume that the vehicle can hold. It is
|
|
|
|
|
* a float value.
|
|
|
|
|
* @param priceConstraint A pointer to a float variable representing the maximum budget constraint.
|
|
|
|
|
* @param tabWeight An array containing the weights of each item in the inventory.
|
|
|
|
|
* @param tabVolume tabVolume is an array that stores the volume of each item in the inventory.
|
|
|
|
|
* @param tabUnitPrice tabUnitPrice is an array that stores the unit price of each item in the
|
|
|
|
|
* inventory.
|
|
|
|
|
* @param tabQuantity tabQuantity is an array that stores the quantity of each item in the shopping
|
|
|
|
|
* cart.
|
|
|
|
|
* @param tlog The parameter "tlog" represents the number of items in the inventory or the number of
|
|
|
|
|
* items in the transaction log.
|
|
|
|
|
* @param cagnotte A pointer to a float variable representing the amount of money available for use.
|
|
|
|
|
*
|
|
|
|
|
* @return an integer value.
|
|
|
|
|
*/
|
|
|
|
|
// 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)
|
|
|
|
|
{
|
|
|
|
|
float totalWeight = 0, totalVolume = 0, totalPrice = 0, cagnotteUse;
|
|
|
|
@ -99,7 +120,7 @@ int constraintExceeded(float weightConstraint, float volumeConstraint, float *pr
|
|
|
|
|
int basket_add (int tab_reference[], float weight[], float volume[], float unitPrice[], float *cagnotte, int basket_tab_ref[], int basket_tab_qte[],int tlog, int tlog_basket)
|
|
|
|
|
{
|
|
|
|
|
int ref_to_add, qte_to_add, trouve, index_ajout, i;
|
|
|
|
|
float total_weight=0, total_volume=0, total_price=0, total_cagnotte=0;
|
|
|
|
|
float total_weight[], total_volume[], total_price[], total_cagnotte[];
|
|
|
|
|
printf("Quelle référence souhaitez-vous ajouter au panier?");
|
|
|
|
|
scanf("%d", &ref_to_add);
|
|
|
|
|
index_ajout = searchTab(tab_reference, ref_to_add, tlog, &trouve);
|
|
|
|
@ -119,17 +140,17 @@ int basket_add (int tab_reference[], float weight[], float volume[], float unitP
|
|
|
|
|
}
|
|
|
|
|
basket_tab_qte[index_ajout] = ref_to_add;
|
|
|
|
|
|
|
|
|
|
for (i=0; i<tlog_basket; i++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
index_ajout = basket_tab_ref[i];
|
|
|
|
|
|
|
|
|
|
total_weight = total_weight + weight[index_ajout]*qte_to_add;
|
|
|
|
|
total_volume = total_volume + volume[index_ajout]*qte_to_add;
|
|
|
|
|
total_price = total_price + unitPrice[index_ajout]*qte_to_add;
|
|
|
|
|
}
|
|
|
|
|
total_weight[i] = total_weight + weight[index_ajout]*qte_to_add;
|
|
|
|
|
total_volume[i] = total_volume + volume[index_ajout]*qte_to_add;
|
|
|
|
|
total_price[i] = total_price + unitPrice[index_ajout]*qte_to_add;
|
|
|
|
|
|
|
|
|
|
*cagnotte = *cagnotte + *cagnotte*0.10;
|
|
|
|
|
|
|
|
|
|
basket_add()
|
|
|
|
|
display_basket();
|
|
|
|
|
//paramètres à poser
|
|
|
|
|
|
|
|
|
|
tlog_basket = tlog_basket+1;
|
|
|
|
|
return tlog_basket;
|
|
|
|
|