From a1bbc0408bfb907f215901ae16936e0f0e4dd506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20LAVERGNE?= Date: Mon, 6 Nov 2023 13:00:52 +0100 Subject: [PATCH] Correction d'erreurs de compilation --- src/display.c | 10 +++++----- src/main.h | 4 ++-- src/modif.c | 18 +++++++++--------- src/panier.c | 12 ++++++------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/display.c b/src/display.c index 53548af..5127a09 100644 --- a/src/display.c +++ b/src/display.c @@ -2,7 +2,7 @@ void displayItem(int tabReference[], float weight[], float volume[], float unitPrice[], int tlog) { - int reference, index; + int reference, index, found; printf("Entrez la référence de l'article cherché: "); scanf("%d", &reference); while (reference < 0) @@ -10,7 +10,7 @@ void displayItem(int tabReference[], float weight[], float volume[], float unitP printf("Erreur, la référence doit être positive, entrez la référence de l'article cherché: "); scanf("%d", &reference); } - index = recherche(reference, tabReference, tlog); + index = searchTab(tabReference, reference, tlog, &found); if (index == -1) { printf("La référence cherchée n'existe pas"); @@ -58,7 +58,7 @@ void displayClient(int clientID[], float cagnotte[], int suspended[], int isAdmi +var id: identifiant du client recherché +var index: index de l'article recherché dans le tableau */ - int id, index; + int id, index, found; printf("Entrez le numéro du client cherché: "); scanf("%d", &id); while (id < 0) @@ -66,7 +66,7 @@ void displayClient(int clientID[], float cagnotte[], int suspended[], int isAdmi printf("Erreur, le numéro du client doit être positif, entrez le numéro du client cherché: "); scanf("%d", &id); } - index = recherche(id, clientID, tlog); + index = searchTab(clientID, id, tlog, &found); if (index == -1) { printf("Le client cherché n'existe pas"); @@ -114,7 +114,7 @@ void displayClientList(int clientID[], float cagnotte[], int suspended[], int is */ void display_basket(int basket_tab_ref[], int basket_qte[], float weight[], float volume[], float unitPrice[], float *cagnotte,float weight_constraint, float volume_constraint, int tlog, int tlog_basket) { - float total_weight_line[], total_volume_line[], total_price_line[], cagnotte_line[], total_weight, total_volume, total_price; + 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; int i; for (i=0; iindex; i--) { @@ -180,7 +180,7 @@ void deleteItem(int tabReference[], float tabWeight[], float tabVolume[], float void deleteClient(int clientID[], float cagnotte[], int suspended[], int isAdmin[], int *tlog) { - int numClient = -1, index, i; + int numClient = -1, index, i, found; while (numClient != 0) { printf("Entrez l'identifiant du client à supprimer ou 0 si vous souhaitez arrêter la saisie: "); @@ -190,12 +190,12 @@ void deleteClient(int clientID[], float cagnotte[], int suspended[], int isAdmin printf("Erreur, le numéro du client doit être positif, entrez le numéro du client ou 0 si vous souhaitez arrêter la saisie: "); scanf("%d", &numClient); } - index = recherche(numClient, clientID, *tlog); + index = searchTab(clientID, numClient, *tlog, &found); while (index == -1) { printf("Cet identifiant client n'existe pas, réessayer ou tapez 0 si vous souhaitez arrêter la saisie: "); scanf("%d", &numClient); - index = recherche(numClient, clientID, *tlog); + index = searchTab(clientID, numClient, *tlog, &found); } for (i=*tlog; i>index; i--) { diff --git a/src/panier.c b/src/panier.c index 8dfb8c0..6264c19 100644 --- a/src/panier.c +++ b/src/panier.c @@ -51,7 +51,6 @@ void clientConstraint(float *weight, float *volume, float *price) * @return an integer value. */ // TODO réécrire cette documentation -//! ERREUR à corriger !! 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; @@ -125,7 +124,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[], total_volume[], total_price[], total_cagnotte[]; + 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); index_ajout = searchTab(tab_reference, ref_to_add, tlog, &trouve); @@ -148,14 +147,15 @@ int basket_add (int tab_reference[], float weight[], float volume[], float unitP index_ajout = basket_tab_ref[i]; - 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; + 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; tlog_basket = tlog_basket+1; - display_basket( basket_tab_ref[], basket_tab_qte[], weight[], volume[], unitPrice[], *cagnotte, weight_constraint, volume_constraint, tlog, tlog_basket); + //! A corriger + //display_basket(basket_tab_ref, basket_tab_qte, weight, volume, unitPrice, *cagnotte, weight_constraint, volume_constraint, tlog, tlog_basket); return tlog_basket; }