From f27c09fa6fcb39547c865f756951b5f031ecb784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=A9o=20Hersan?= Date: Tue, 31 Oct 2023 18:36:16 +0100 Subject: [PATCH] fixed delete article MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathéo Hersan --- app | Bin 52816 -> 52816 bytes src/app/core_logic/client.c | 151 ------------------------ src/app/core_logic/client.h | 33 +----- src/app/interface/interface_client.c | 167 ++++++++++++++++++++++++++- src/app/interface/interface_client.h | 40 +++++++ 5 files changed, 207 insertions(+), 184 deletions(-) diff --git a/app b/app index 490afcb349638e3f68ef2d523db7409db8f661b4..1e4860e1386ae6643b084d4bedaf449c41a8dfc8 100755 GIT binary patch delta 6960 zcmZu$3tZGy_P@X1{N@D=f*>gG5tN7WMo>T)9t9c_D)>Sk<1jo7VI078HD?SfYe~6X z%Jf4m+6$Avx?u&bsD*80lv7!e)&5c08r!z0Wp|;Z*>isn#gxxyX3qDXbH4Z7bI-lM zdwD3Xr7zBi}%Xzs-xGAvuj43Syf{qDB&2o->NIDBX{LEYQ9?cpRS z+TGF-jE9}k#4E0-EeN4j)CpLLCSH*6_rbUWda1MS-lAoQ6_epX=C~lEtRT$PjE`iZ7{HP?ihT~?CJDSVJcae{x!-B@b@fK)+ z?0a@X<8>LrVGNq!BTkLLW-=?rz!Z>&V!XZhw%iDu5B6U;9Nv@LGmkj>$+|U<1dpQe z2plHzP>xO+`w``Vl#C+a32`OA#dt9@fXL6ibsqKr+wXyc_Uq(I(v04uWbHKWs55FK zrnSDwqsTfRPijyb%!?=e*ua=4YmdbLg?8%5cjR$-bsvX10$Zu0 zFEq5HZtc1#MmdUxqi~CctSSx%d1f@WYRIF-ksyym;|2{mRUGL(icZAfO0hG(bC}Z& z8uD9l6z5MPjai?>jRtMXCJ(I71JA9oI8H;(tj`D?MT4<8Nc6N<>3UUi4IyFiuH>-x~S*#UOQF)W!$ z-p6eL9s*rw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#@cQu8sK+FoG z-J7Tz$2JlJu9aC_Bh0QW@ybu5>B!NjI@i+RNM%8E`>z-=H!J}+%pNDdjW;XX#KOUw zFNny;4=O&Vu0VR#jxI;lR~$^SjPB~FsTl?TyCMwgEFn-_;|1OiALPoR@8LxJ|AYN^ z#a3H**i)U^wd`>ZUc2K(_Up-jYHOs9eIlBLuCuEYc3UIj8%4s+bS8Y2Ga(HDgzF0; z{M8^r;vW{YgYeE>(5Sz*vB4$w5}l{*}ef|!e`bsn9Hh7 zM3+@!Bq;p*&89ll#w>wsd>s32 z7W_L?Kf-!-R<%_!zfvSeH!&M+#c1yIQ6@HHKKL@DrNm;aL2H<+dJEaXVVmsIvs|5t zyvz~jOcF1TT2C_bYRkHnP zHIPrAgoN_FTNp70eF=CUesjALPqTO_4VkxVufrML}J@7jn>Xat1?$qAT7&OZ>%Hl3AN=o;k=poq!)SJ zA2UW7IU$sV;g#4&$oTrb=U7Ir&_}>WJ)e!Z>#@%ctLD zmX%T zt|>RIDIs6s(rYU|%GtO}nm#z&n=Cfz26^!PAk-R^CV#fYgCFt0F}G*Rc)EhuOp|e* zg7Z^lyi~!LvSeJV;CTEZhGxi<3f_nt8N<62oS!7)H)U)kXYk82BOFl(M`y_R3k9oR zs4ptGuvG46$1Ub?^Sv^5Mw#Kp*)nElEryfk$#{Z-OABS3DPjC9?SmT|%A`OcgcQiQ zLczTiGG49V&UhKK3S|S>lmYfAIAnp`|E7YwO)~xu1-DL?v5jFX{;H(lI+XixVKfBoS3 zRi~R%K8hSw*XrZ;?zUyY+QX$!Cd|*Qn|i@7?LfzC@9#YKwny`exv^)zX!~RDV0h~! zbIbT6jZ=R*QGVj`>C8PVx9j#q{k`l(?kap chargeMaximale) { - depassementCharge = poidsTotal - chargeMaximale; - } - - if (volumeTotal > volumeCoffre) { - depassementVolume = volumeTotal - volumeCoffre; - } - - if (budget > 0 && montantTotal > budget) { - depassementBudget = montantTotal - budget; - } - - if (depassementCharge || depassementVolume || depassementBudget) { - printf("Attention : \n"); - if (depassementCharge) { - printf("\tDépassement de la charge autorisée de %.2f kg \n", depassementCharge); - } - if (depassementVolume) { - printf("\tDépassement du volume autorisé de %.2f litres \n", depassementVolume); - } - if (depassementBudget) { - printf("\tDépassement du budget autorisé de %.2f euros \n", depassementBudget); - } - printf("\n"); - } else { - float montantTotal = prixUnitaire[articleIndex] * quantite; - - int clientIndex = trouver_index_client(numeroClient, numeros, nombreClients); - - if (clientIndex != -1) { - cagnottes[clientIndex] += 0.1 * montantTotal; - } - - panier[*taillePanier] = reference; - quantites[*taillePanier] = quantite; - (*taillePanier)++; - - printf("Contenu du panier : "); - for (int i = 0; i < *taillePanier; i++) { - printf("%d ", panier[i]); - } - printf("\n"); - - printf("Référence : %d\nQuantité : %d\n", reference, quantite); - printf("Récap :\n"); - printf("Réf Qté Poids Vol PrixU PoidsTot VolTot PrixTot Cagnotte\n"); - printf("%d %d %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n", - reference, quantite, poids[articleIndex], volume[articleIndex], - prixUnitaire[articleIndex], poidsTotal, volumeTotal, montantTotal, - cagnottes[clientIndex]); - printf("Prix total à payer: %.2f euros\n", montantTotal); - printf("Cagnotte totale : %.2f euros\n", cagnottes[clientIndex]); - printf("Volume utilise : %.2f litres\n", volumeTotal); - printf("Volume restant : %.2f litres\n", volumeCoffre - volumeTotal); - printf("Charge Actuelle: %.2f kg\n", poidsTotal); - printf("Charge restante: %.2f kg\n", chargeMaximale - poidsTotal); - } -} - - -/** - * @brief Supprime un article du panier du client. - * - * Cette fonction permet de supprimer un article du panier du client. - * - * @param panier - Tableau des références des articles dans le panier. - * @param quantites - Tableau des quantités de chaque article dans le panier. - * @param taillePanier - Taille du panier. - */ -void supprimer_article_du_panier(int panier[], int quantites[], int *taillePanier) { - int reference; - printf("Entrez la référence de l'article à supprimer : "); - while (scanf("%d", &reference) != 1) { - while (getchar() != '\n'); - printf("ERREUR : Veuillez entrer une référence valide (nombre) : "); - } - while (getchar() != '\n'); - - int articleIndex = trouver_index_article(reference, panier, *taillePanier); - - if (articleIndex == -1) { - printf("Article non trouvé dans le panier. Veuillez entrer une référence valide.\n"); - return; - } - - for (int i = articleIndex; i < (*taillePanier - 1); i++) { - panier[i] = panier[i + 1]; - quantites[i] = quantites[i + 1]; - } - - (*taillePanier)--; - - printf("Article supprimé du panier avec succès.\n"); -} /** * @brief Affiche un récapitulatif du contenu du panier. diff --git a/src/app/core_logic/client.h b/src/app/core_logic/client.h index c3f9717..20941fb 100644 --- a/src/app/core_logic/client.h +++ b/src/app/core_logic/client.h @@ -3,6 +3,7 @@ #include #include +#include "../interface/interface_client.h" /** * @file client.h @@ -34,38 +35,6 @@ int charger_clients(int numeros[], float cagnottes[], int suspendues[], int tPhy */ void sauvegarde_clients(int numeros[], float cagnottes[], int suspendus[], int nombreClients); -/** - * @brief Ajoute un article au panier du client. - * - * @param numeroClient - Numéro du client. - * @param references - Tableau des références des articles. - * @param poids - Tableau des poids des articles. - * @param volume - Tableau des volumes des articles. - * @param prixUnitaire - Tableau des prix unitaires des articles. - * @param numeros - Tableau des numéros de clients. - * @param cagnottes - Tableau des cagnottes des clients. - * @param suspendues - Tableau des états de suspension des clients. - * @param nombreArticles - Nombre d'articles disponibles. - * @param nombreClients - Nombre de clients. - * @param volumeCoffre - Volume total du coffre. - * @param chargeMaximale - Charge maximale du coffre. - * @param panier - Tableau des références des articles dans le panier. - * @param quantites - Tableau des quantités de chaque article dans le panier. - * @param taillePanier - Taille du panier. - * @param budget - Budget du client. - */ -void ajouter_article_au_panier(int numeroClient, int references[], float poids[], float volume[], float prixUnitaire[], - int numeros[], float cagnottes[], int suspendues[], int nombreArticles, int nombreClients, - float volumeCoffre, float chargeMaximale, int panier[], int quantites[], int *taillePanier, float budget); - -/** - * @brief Supprime un article du panier du client. - * - * @param panier - Tableau des références des articles dans le panier. - * @param quantites - Tableau des quantités de chaque article dans le panier. - * @param taillePanier - Taille du panier. - */ -void supprimer_article_du_panier(int panier[], int quantites[], int *taillePanier); /** * @brief Affiche un récapitulatif du contenu du panier. diff --git a/src/app/interface/interface_client.c b/src/app/interface/interface_client.c index 060c539..1097bd3 100644 --- a/src/app/interface/interface_client.c +++ b/src/app/interface/interface_client.c @@ -41,6 +41,170 @@ void menu_client(int *choix) { } } +/** + * @brief Ajoute un article au panier du client. + * + * Cette fonction permet d'ajouter un article au panier du client. + * + * @param numeroClient - Numéro du client. + * @param references - Tableau des références des articles. + * @param poids - Tableau des poids des articles. + * @param volume - Tableau des volumes des articles. + * @param prixUnitaire - Tableau des prix unitaires des articles. + * @param numeros - Tableau des numéros de clients. + * @param cagnottes - Tableau des cagnottes des clients. + * @param suspendues - Tableau des états de suspension des clients. + * @param nombreArticles - Nombre d'articles disponibles. + * @param nombreClients - Nombre de clients. + * @param volumeCoffre - Volume total du coffre. + * @param chargeMaximale - Charge maximale du coffre. + * @param panier - Tableau des références des articles dans le panier. + * @param quantites - Tableau des quantités de chaque article dans le panier. + * @param taillePanier - Taille du panier. + * @param budget - Budget du client. + */ +void ajouter_article_au_panier(int numeroClient, int references[], float poids[], float volume[], float prixUnitaire[], + int numeros[], float cagnottes[], int suspendues[], int nombreArticles, int nombreClients, + float volumeCoffre, float chargeMaximale, int panier[], int quantites[], int *taillePanier, float budget) { + + int reference, quantite, articleIndex; + float poidsTotal, montantTotal, volumeTotal, depassementCharge = 0, depassementVolume, depassementBudget = 0; + + while (1) { + printf("Entrez la référence de l'article : "); + while (scanf("%d", &reference) != 1) { + while (getchar() != '\n'); + printf("ERREUR : Veuillez entrer une référence valide (nombre) : "); + } + while (getchar() != '\n'); + + articleIndex = trouver_index_article(reference, references, nombreArticles); + + if (articleIndex == -1) { + printf("ERREUR : Article non trouvé. Veuillez entrer une référence valide.\n"); + } else { + break; + } + } + + printf("Entrez la quantité : "); + while (scanf("%d", &quantite) != 1) { + while (getchar() != '\n'); + printf("ERREUR : Veuillez entrer une quantité valide (nombre) : "); + } + while (getchar() != '\n'); + + poidsTotal = poids[articleIndex] * quantite; + volumeTotal = volume[articleIndex] * quantite; + montantTotal = prixUnitaire[articleIndex] * quantite; + + if (poidsTotal > chargeMaximale) { + depassementCharge = poidsTotal - chargeMaximale; + } + + if (volumeTotal > volumeCoffre) { + depassementVolume = volumeTotal - volumeCoffre; + } + + if (budget > 0 && montantTotal > budget) { + depassementBudget = montantTotal - budget; + } + + if (depassementCharge || depassementVolume || depassementBudget) { + printf("Attention : \n"); + if (depassementCharge) { + printf("\tDépassement de la charge autorisée de %.2f kg \n", depassementCharge); + } + if (depassementVolume) { + printf("\tDépassement du volume autorisé de %.2f litres \n", depassementVolume); + } + if (depassementBudget) { + printf("\tDépassement du budget autorisé de %.2f euros \n", depassementBudget); + } + printf("\n"); + } else { + float montantTotal = prixUnitaire[articleIndex] * quantite; + + int clientIndex = trouver_index_client(numeroClient, numeros, nombreClients); + + if (clientIndex != -1) { + cagnottes[clientIndex] += 0.1 * montantTotal; + } + + panier[*taillePanier] = reference; + quantites[*taillePanier] = quantite; + (*taillePanier)++; + + printf("Contenu du panier : "); + for (int i = 0; i < *taillePanier; i++) { + printf("%d ", panier[i]); + } + printf("\n"); + + printf("Référence : %d\nQuantité : %d\n", reference, quantite); + printf("Récap :\n"); + printf("Réf Qté Poids Vol PrixU PoidsTot VolTot PrixTot Cagnotte\n"); + printf("%d %d %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n", + reference, quantite, poids[articleIndex], volume[articleIndex], + prixUnitaire[articleIndex], poidsTotal, volumeTotal, montantTotal, + cagnottes[clientIndex]); + printf("Prix total à payer: %.2f euros\n", montantTotal); + printf("Cagnotte totale : %.2f euros\n", cagnottes[clientIndex]); + printf("Volume utilise : %.2f litres\n", volumeTotal); + printf("Volume restant : %.2f litres\n", volumeCoffre - volumeTotal); + printf("Charge Actuelle: %.2f kg\n", poidsTotal); + printf("Charge restante: %.2f kg\n", chargeMaximale - poidsTotal); + } +} + + +/** + * @brief Supprime un article du panier du client. + * + * Cette fonction permet de supprimer un article du panier du client. + * + * @param panier - Tableau des références des articles dans le panier. + * @param quantites - Tableau des quantités de chaque article dans le panier. + * @param taillePanier - Taille du panier. + */ +void supprimer_article_du_panier(int panier[], int quantites[], int *taillePanier, float cagnottes[], int numeroClient, int numeros[], int nombreClients, int references[], float prixUnitaire[]) { + int reference; + printf("Entrez la référence de l'article à supprimer : "); + while (scanf("%d", &reference) != 1) { + while (getchar() != '\n'); + printf("ERREUR : Veuillez entrer une référence valide (nombre) : "); + } + while (getchar() != '\n'); + + int articleIndex = trouver_index_article(reference, references, MAX_ARTICLES); + + if (articleIndex == -1) { + printf("Article non trouvé dans le panier. Veuillez entrer une référence valide.\n"); + return; + } + + int quantite = 0; + for (int i = 0; i < *taillePanier; i++) { + if (panier[i] == reference) { + quantite = quantites[i]; + for (int j = i; j < *taillePanier - 1; j++) { + panier[j] = panier[j + 1]; + quantites[j] = quantites[j + 1]; + } + break; + } + } + + (*taillePanier)--; + + int clientIndex = trouver_index_client(numeroClient, numeros, nombreClients); + if (clientIndex != -1) { + float montantTotal = prixUnitaire[articleIndex] * quantite; + cagnottes[clientIndex] -= 0.1 * montantTotal; // Retirer 10% du montant + } + + printf("Article supprimé du panier avec succès.\n"); +} /** * @brief Affiche le récapitulatif du panier. @@ -141,7 +305,8 @@ void global_client() { suspendus, nombreArticles, nombreClients, volumeCoffre, chargeMaximale, panier, quantites, &taillePanier, budget); break; case 3: - supprimer_article_du_panier(panier, quantites, &taillePanier); + //supprimer_article_du_panier(panier, quantites, &taillePanier, prixUnitaire, numeroClient, cagnottes); + supprimer_article_du_panier(panier, quantites, &taillePanier, cagnottes, numeroClient, numeros, nombreClients, references, prixUnitaire); break; case 4: modifier_quantite_article_panier(panier, quantites, &taillePanier); diff --git a/src/app/interface/interface_client.h b/src/app/interface/interface_client.h index ebe7eca..66985b2 100644 --- a/src/app/interface/interface_client.h +++ b/src/app/interface/interface_client.h @@ -20,6 +20,46 @@ void affiche_client(); void menu_client(int *choix); +/** + * @brief Ajoute un article au panier du client. + * + * Cette fonction permet d'ajouter un article au panier du client. + * + * @param numeroClient - Numéro du client. + * @param references - Tableau des références des articles. + * @param poids - Tableau des poids des articles. + * @param volume - Tableau des volumes des articles. + * @param prixUnitaire - Tableau des prix unitaires des articles. + * @param numeros - Tableau des numéros de clients. + * @param cagnottes - Tableau des cagnottes des clients. + * @param suspendues - Tableau des états de suspension des clients. + * @param nombreArticles - Nombre d'articles disponibles. + * @param nombreClients - Nombre de clients. + * @param volumeCoffre - Volume total du coffre. + * @param chargeMaximale - Charge maximale du coffre. + * @param panier - Tableau des références des articles dans le panier. + * @param quantites - Tableau des quantités de chaque article dans le panier. + * @param taillePanier - Taille du panier. + * @param budget - Budget du client. + */ +void ajouter_article_au_panier(int numeroClient, int references[], float poids[], float volume[], float prixUnitaire[], + int numeros[], float cagnottes[], int suspendues[], int nombreArticles, int nombreClients, + float volumeCoffre, float chargeMaximale, int panier[], int quantites[], int *taillePanier, float budget); + + +/** + * @brief Supprime un article du panier du client. + * + * Cette fonction permet de supprimer un article du panier du client. + * + * @param panier - Tableau des références des articles dans le panier. + * @param quantites - Tableau des quantités de chaque article dans le panier. + * @param taillePanier - Taille du panier. + */ +//void supprimer_article_du_panier(int panier[], int quantites[], int *taillePanier, float prixUnitaire[], int clientIndex, float cagnottes[]); + +void supprimer_article_du_panier(int panier[], int quantites[], int *taillePanier, float cagnottes[], int numeroClient, int numeros[], int nombreClients, int references[], float prixUnitaire[]); + /** * @brief Affiche le récapitulatif du panier. *