début de l'ajout du menu client et fix de bugs

doc
Louis GERMAIN 2 years ago
parent e369770244
commit b27e0ccbab

@ -108,53 +108,30 @@ void displayClientList(int clientID[], float cagnotte[], int suspended[], int is
* @param cagnotte: pointeur indiquant la valeur de la cagnotte
* @param tlog: taille logique du tableau `tab_reference`
* @param tlog_basket: taille logique du panier
* @return Rien
* @return void
*/
void display_basket(int basket_tab_ref[], int basket_qte[], float weight[], float volume[], float unitPrice[], int tlog, int tlog_basket)
void display_basket(int basket_tab_ref[], int basket_qte[], float weight[], float volume[], float cagnotte[], float unitPrice[], int tlog, int tlog_basket)
{
float total_weight_line[tlog_basket], total_volume_line[tlog_basket], total_price_line[tlog_basket], cagnotte_line[tlog_basket], total_weight, total_volume, total_price;
float total_weight_line[tlog_basket], total_volume_line[tlog_basket], total_price_line[tlog_basket];
float totalWeight = 0, totalVol = 0, total_price = 0;
int i;
for (i=0; i<tlog_basket; i++)
{
total_weight_line[i] = basket_qte[i]*weight[i];
total_volume_line[i] = basket_qte[i]*volume[i];
total_price_line[i] = basket_qte[i]*unitPrice[i];
cagnotte_line[i] = total_price_line[i] * 0.10;
}
for (i=0; i<tlog_basket; i++)
{
total_price = total_price + total_price_line[i];
totalWeight += total_weight_line[i];
totalVol += total_volume_line [i];
total_price += total_price_line[i];
}
printf("Récapitulatif de votre panier:\n");
printf("Référence\tQuantité\tPoids\tVolume\tPrixU\tPoidsTot\tVolTot\tPrixTot\tCagnotte\n");
printf("Référence\tQuantité\tPoids\tVolume\tPrix unitaire\tPoids Total\tVol Total\tPrix Total\n");
for (i=0; i<tlog_basket; i++)
printf("%d\t%d\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n", basket_tab_ref[i], basket_qte[i], weight[i], volume[i], unitPrice[i], total_weight_line[i], total_volume_line[i], total_price_line[i],cagnotte_line[i]);
printf("%d\t%d\t%f\t%f\t%f\t%f\t%f\t%f\n", basket_tab_ref[i], basket_qte[i], weight[i], volume[i], unitPrice[i], total_weight_line[i], total_volume_line[i], total_price_line[i]);
printf("\t\t\t\t\tPrix total à payer: %f\t euros\n", total_price);
//constraintExceeded( weightConstraint, volumeConstraint, *priceConstraint, *cagnotte, tabWeight[], tabVolume[], tabPrice[], tabItemRef[], tabBasketRef[], tabBasketQuantity[], tlogItem, int tlogBasket)
// if (volume_constraint<total_volume)
// {
// printf("Volume actuel:%.2f\n", total_volume);
// printf("Volume restant: Attention, dépasssement du volume autorisé de %2.f, veuillez suprimer des articles",total_volume - volume_constraint);
// }
// else
// {
// printf("Volume actuel:%.2f\n", total_volume);
// printf("Volume restant:%2.f\n", volume_constraint - total_volume);
// }
// if (weight_constraint<total_weight)
// {
// printf("Charge actuelle:\t%2.f",total_weight);
// printf("Attention, dépasssement de la charge autorisée de %2.f, veuillez suprimer des articles", total_weight - weight_constraint);
// }
// else
// {
// printf("Charge actuelle:\t%2.f",total_weight);
// printf("Charge restante:\t%2.f", volume_constraint - total_volume);
// }
printf("Prix total: %f€\n", total_price);
printf("Poids total: %fkg\n", totalWeight);
printf("Volume total: %fm³\n", totalVol);
}

@ -48,9 +48,8 @@ int searchTab(int targetTab[], int valSearched, int tLog, int *found);
//! PANIER
void clientConstraint(float *weight, float *volume, float *price);
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 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);
void display_basket(int basket_tab_ref[], int basket_qte[], float weight[], float volume[], float unitPrice[], int tlog, int tlog_basket);
int reinit_basket(int tlog_basket);
int basket_add (int tab_reference[], float unitPrice[], float *cagnotte, int basket_tab_ref[], int basket_tab_qte[], int tlog, int tlog_basket);
void display_basket(int basket_tab_ref[], int basket_qte[], float weight[], float volume[], float cagnotte[], float unitPrice[], int tlog, int tlog_basket);
int basket_del_article( int basket_tab_ref[], int basket_tab_qte[], int tlog_basket);
//! LOGIN
@ -59,4 +58,8 @@ int signup(int clientID[], int clientPassword[], float cagnotte[], int suspended
//! MOT DE PASSE
int encrypt(int password);
int decrypt(int password);
int decrypt(int password);
//! MENUS
void adminMenu(void);
void clientMenu(float *weight, float *volume, float *price);

@ -5,7 +5,46 @@
#include "main.h"
void clientMenu()
void clientMenu(float *weight, float *volume, float *price)
{
int choice = 0;
while (choice != 6)
{
printf("\n=================================\n");
printf(" Menu Client\n");
printf("=================================\n");
printf("1\u2022 Entrer ses contraintes\n");
printf("2\u2022 Ajouter un article au panier\n");
printf("3\u2022 Afficher le panier\n");
printf("4\u2022 Réinitialiser le panier\n");
printf("5\u2022 Retirer un article du panier\n");
printf("6\u2022 Quitter\n");
printf("=================================\n");
printf("Votre choix: ");
scanf("%d", &choice);
switch (choice)
{
case 1:
clientConstraint(weight, volume, price);
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
return;
default:
printf("Erreur, veuillez entrer un choix valide.\n");
break;
}
}
}
void adminMenu(void)
{
}

@ -123,9 +123,9 @@ int constraintExceeded(float weightConstraint, float volumeConstraint, float *pr
* @param tlog_basket: taille logique du panier
* @return taille logique du panier
*/
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 basket_add (int tab_reference[], 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;
int ref_to_add, qte_to_add, trouve, index_ajout;
float total_weight[tlog_basket], total_volume[tlog_basket], total_price[tlog_basket], total_cagnotte[tlog_basket];
printf("Quelle référence souhaitez-vous ajouter au panier?");
scanf("%d", &ref_to_add);
@ -145,15 +145,8 @@ int basket_add (int tab_reference[], float weight[], float volume[], float unitP
scanf("%d", &qte_to_add);
}
basket_tab_qte[index_ajout] = ref_to_add;
index_ajout = basket_tab_ref[i];
total_weight[i] += weight[index_ajout]*qte_to_add;
total_volume[i] += volume[index_ajout]*qte_to_add;
total_price[i] += unitPrice[index_ajout]*qte_to_add;
*cagnotte = *cagnotte + *cagnotte*0.10;
*cagnotte += (unitPrice[index_ajout]*qte_to_add) *0.1;
tlog_basket = tlog_basket+1;
return tlog_basket;
@ -164,12 +157,11 @@ int basket_add (int tab_reference[], float weight[], float volume[], float unitP
* @param tlog_basket: taille logique du panier
* @return taille logique du panier
*/
int reinit_basket(int tlog_basket)
void reinit_basket(int *tlog_basket)
{
tlog_basket=0;
*tlog_basket=0;
// En mettant tlog_basket à 0,
// on fait comme si la taille logique était à 0, faisant que l'on ne considère plus aucun élément des tableaux
return tlog_basket;
}
/**

Loading…
Cancel
Save