From 26889a4ee5e613ecfb5e5091cbc173b72b79dfdd Mon Sep 17 00:00:00 2001 From: mahersan Date: Fri, 20 Oct 2023 17:15:19 +0200 Subject: [PATCH 01/22] Added chargerClient --- src/app/core_logic/client.c | 25 ++++++++++++------------- src/app/core_logic/client.h | 2 +- src/main.c | 2 ++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/app/core_logic/client.c b/src/app/core_logic/client.c index 04040fd..d5e75e2 100644 --- a/src/app/core_logic/client.c +++ b/src/app/core_logic/client.c @@ -4,21 +4,20 @@ #include "client.h" -void afficherDonneesClient() { - FILE *fichier = fopen("donnee/client.txt", "r"); - int numeroClient; - float cagnotte; - int suspendu; - - if (fichier == NULL) { - fprintf(stderr, "Erreur lors de l'ouverture du fichier"); +void chargerClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique) +{ + FILE *fic; + int i; + fic = fopen("donnee/client.txt", "r"); + if (fic == NULL) + { + perror("fopen"); exit(EXIT_FAILURE); } - while (fscanf(fichier, "%d%f%d", &numeroClient, &cagnotte, &suspendu) == 3) { - printf("Client %d, Cagnotte %.2f, Suspendu: %s\n", - numeroClient, cagnotte, (suspendu == 0) ? "Non" : "Oui"); + while (fscanf(fic, "%d %f %d", &tNumClient[*tLogique], &tCagnotte[*tLogique], &tSus[*tLogique]) != EOF) + { + (*tLogique)++; } - - fclose(fichier); + fclose(fic); } \ No newline at end of file diff --git a/src/app/core_logic/client.h b/src/app/core_logic/client.h index aff2be5..e173a26 100644 --- a/src/app/core_logic/client.h +++ b/src/app/core_logic/client.h @@ -8,6 +8,6 @@ #include #include -void afficherDonneesClient(); +void chargerClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique); #endif //SAE_101_CLIENT_H diff --git a/src/main.c b/src/main.c index 106da06..d65ed5f 100644 --- a/src/main.c +++ b/src/main.c @@ -26,5 +26,7 @@ int main(){ //case 1: global_resp(); case 2: global_client(); } + + chargerClient(); return 0; } From 62203ccd46c44febbb7d5c96e47191f7cd81068f Mon Sep 17 00:00:00 2001 From: Yannis Doumir Fernandes Date: Fri, 20 Oct 2023 17:31:37 +0200 Subject: [PATCH 02/22] ADD chargementArticles() --- src/app/core_logic/responsable.c | 27 +++++++++++++++++++++++++++ src/app/core_logic/responsable.h | 3 +++ src/app/core_logic/testResponsable.c | 12 ++++++++++++ src/app/interface/interface_resp.c | 4 ++-- src/app/interface/interface_resp.h | 2 +- 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 src/app/core_logic/testResponsable.c diff --git a/src/app/core_logic/responsable.c b/src/app/core_logic/responsable.c index e69de29..6da8f11 100644 --- a/src/app/core_logic/responsable.c +++ b/src/app/core_logic/responsable.c @@ -0,0 +1,27 @@ +#include +#include "responsable.h" + +int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], float tPhysique) +{ + int i=0, ref; + float volume, poids, prix; + FILE * fe; + fe = fopen("donnee/articles.txt", "r"); + if ( fe == NULL) + { + perror("fopen"); + } + while ( fscanf(fe,"%d %f %f %f", &ref, &poids, &volume, &prix) == 4) + { + if ( i == tPhysique ) + { + fprintf(stderr,"Tableau plein"); + } + tRef[i] = ref; + tPoids[i] = poids; + tVol[i] = volume; + tPrix[i] = prix; + i++; + } + return i; +} \ No newline at end of file diff --git a/src/app/core_logic/responsable.h b/src/app/core_logic/responsable.h index e69de29..8bee266 100644 --- a/src/app/core_logic/responsable.h +++ b/src/app/core_logic/responsable.h @@ -0,0 +1,3 @@ + + +int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], float tPhysique); \ No newline at end of file diff --git a/src/app/core_logic/testResponsable.c b/src/app/core_logic/testResponsable.c new file mode 100644 index 0000000..9759553 --- /dev/null +++ b/src/app/core_logic/testResponsable.c @@ -0,0 +1,12 @@ +#include +#include "responsable.h" +#include "../interface/interface_resp.h" + +int main (void) +{ + int tPhysique = 10, tRef[10], tLogique = 0; + float tPoids[10], tVol[10], tPrix[10]; + tLogique = chargementArticles( tRef, tPoids, tVol, tPrix, tPhysique); + affichArticles( tRef, tPoids, tVol, tPrix, tLogique); + return 0; +} \ No newline at end of file diff --git a/src/app/interface/interface_resp.c b/src/app/interface/interface_resp.c index be2d6ef..650d3fc 100644 --- a/src/app/interface/interface_resp.c +++ b/src/app/interface/interface_resp.c @@ -1,12 +1,12 @@ #include #include "interface_resp.h" -void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], int tPhysique) +void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique) { int i; printf("______________________________________\n"); printf("\t Liste des articles \n\n"); - for ( i = 0; i < tPhysique; ++i) + for ( i = 0; i < tLogique; ++i) { printf("\t %d %.2f %.2f %.2f\n\n", tRef[i], tPoids[i], tVol[i], tPrix[i]); } diff --git a/src/app/interface/interface_resp.h b/src/app/interface/interface_resp.h index ef6bc7a..480a299 100644 --- a/src/app/interface/interface_resp.h +++ b/src/app/interface/interface_resp.h @@ -1,4 +1,4 @@ -void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], int tPhysique); +void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique); void affichUnArticle(int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique, int val); void affichUnClient(int tNumClient[], float tCagnotte[], int tSus[], int tLogique, int val); void affichUnClients(int tNumClient[], float tCagnotte[], int tSus[], int tLogique, int val); \ No newline at end of file From 47527dcd567b1e2a71cb6231325921adee50cc50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=A9o=20Hersan?= Date: Tue, 24 Oct 2023 09:59:58 +0200 Subject: [PATCH 03/22] some modifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathéo Hersan --- app | Bin 0 -> 34224 bytes donnee/panier.txt | 4 ++++ src/app/core_logic/client.c | 24 ++------------------- src/app/core_logic/client.h | 2 +- src/app/core_logic/responsable.h | 2 -- src/app/core_logic/testResponsable.c | 9 -------- src/app/interface/interface_client.c | 30 ++++++++++++++++++++++----- src/main.c | 2 +- 8 files changed, 33 insertions(+), 40 deletions(-) create mode 100755 app create mode 100644 donnee/panier.txt diff --git a/app b/app new file mode 100755 index 0000000000000000000000000000000000000000..d63c7bbbd32e1cf3bb664966930adf92e59f9179 GIT binary patch literal 34224 zcmeI5e{fXQ702(}B_<>yH zwP_bETHEGLosmDJE(+r=W5-n6adDE8cBd8@wt)$coa` zaN~+^uDEqAwdN;2Ilt*ViS+EoKt*X@v7tG?o6mRWw=q*LLNjG7i6=#gsM{l^fTB>} z$}0_HcDal(B$HjaG>&!W>ZmA6I1+6M=b8%j9lhGnM+_*DY}Z#}>H|Zb6vZ2kgtWls zoSbj(w0c9|Psk`FlI_W^o7xp68u*qLXjQa;FUaM5eTnM~eH%NWY%dU*WsR>qbv)=ldpFZZHYY|6cm&p;+NUqnuQm$7n` za*VMdl;e?`knM?lO1aqHSWwS=kFkjbZ6r=YmXT?GZ8RLJ^=mD)t)2c>$dtZ>OzWsG zi^irra?RT0>~}7kddsS_i_j(`8#a-aNxV+%S@FM}^HFg7NJgrHeWa%cacNKV+&X0H zGvc8R#H7)+U_I+P!x6Q;=K30}OKUM^e-#DkkAn}*ooC9#i_%PF>X&!nnZ_ciStLO~ z5D)|e0YN|z5CjAPK|l}?1Ox#=KoAfF1OY)n5D)|e0YN|z5CjAPK|l}?1Ox#=KoAfF z1OY)n5D)|e0YN|z5CjAPK|m1rKO!)aX2*tiI+DXNrpMEjDJ;E*HC5?@#VqS{u!p$3 z0kV^2TP!(Vr7NfpI^EfgR2I9lcUXPzV(fU9z1@H|*YwY+u5Du?zpR;J>OO6usy$isZii5h(= z<|Jau&?zU=t0b1??PqHA#c0Q$Ku@E-63Kn2L}FVr&ptY%%E6XVJL!4Ore`+B^SS@6 z(Pv#iX9e0%kBm&uTVqTD+oI%fqogOw*|7|`5aYyGP@jx?tg4(ubymLizBqp5~ z4~Juwsl$i|_AaX(ENA_Llaa@>{(Uhe6^9?T!nX-pYcV@iQUu>me{@EM8NSaHB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0>~&_!$a~@S-m>P$s@ODYCujWDKI!8D(%pNnpeA6T!UgML$KuhP%qDEMN<>U2*Jml z%@LSVQ=SFpc;yqNQs$CZYj{Bv4hmb_CM=gyJ02^~safQ+f1;zo+*=xAF&N$EY4NMZ zU_N$ED~2@s0U;vWN3;e50adLv<0)Jd!Ry^2<_mVH0Yo@i#s9~eNgo08t6G3H@+jv% zfigAZ^LSO_v#>_K$&%%{AvN3)41{Us+Th>kb@n&x~>7$arZ;a9yRMw5}F5Ygwv)#=_@gWEZ z0)l`bAP5Kof`A|(2nYg#fFK|U2m*qDARq_`0)l`bAP5Kof`A|(2nYg#fFK|U2m*qD zARq_`0)l`bAP5Kof`A|(2nYg#fFK|U2m*qDARq_`0)l`bAP5Kof`A|(2nYg#fFK|U z2m+rQ0U4Tbmk#Sdrr$a@?gBss$#zKq|2=S{)%b02=EiLRZmY$ZC*cAC2|pYz;fKVf zI^>ne8<5+~akzXU9BEZUp$?`PmpmvwT(%O3_#lV9o&d@YbO%Ey&32>NP#`I+pB6|L z6*yV%W_;|{@bO?fKK9%#h1qoGFmIw@Q;o|U*yT=kl0RgC);*fJ;E z?}bW!xeQxwT#llcH&U?mPIe*y<&SK|5Km~c+KwwMa+)HzZ6$Z(1nYFN9v{Z`gz?ec zLKARV#Q{kTMA<=!6)Ej)in?9(;yN0oP4$2Sb9vYu-Zpm6W`D57ZCYmT=1t65+TMc`_=!_`!RU>37^o-o3<-mznaOs|*=; zA@TkPml`r$#AUimg65OEX#W0%hTLh&cR~^M|Im~lAs?f@*Obf5=i@FcKA(Pk~SJQ4CFvNpO@bJBW23*m$aP|=Kk{6AE*Db q_P6cb@#2XJe`MW^uG25PcliU8{`IW4@~8DRk3W0z?35c8toa`~r9TM( literal 0 HcmV?d00001 diff --git a/donnee/panier.txt b/donnee/panier.txt new file mode 100644 index 0000000..4997cb6 --- /dev/null +++ b/donnee/panier.txt @@ -0,0 +1,4 @@ +32 +660 +5079 +8043 \ No newline at end of file diff --git a/src/app/core_logic/client.c b/src/app/core_logic/client.c index d5e75e2..5366f5f 100644 --- a/src/app/core_logic/client.c +++ b/src/app/core_logic/client.c @@ -1,23 +1,3 @@ -// -// Created by Mathéo Hersan on 16/10/2023. -// +#include -#include "client.h" - -void chargerClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique) -{ - FILE *fic; - int i; - fic = fopen("donnee/client.txt", "r"); - if (fic == NULL) - { - perror("fopen"); - exit(EXIT_FAILURE); - } - - while (fscanf(fic, "%d %f %d", &tNumClient[*tLogique], &tCagnotte[*tLogique], &tSus[*tLogique]) != EOF) - { - (*tLogique)++; - } - fclose(fic); -} \ No newline at end of file +//fonction ajouter un article au panier. diff --git a/src/app/core_logic/client.h b/src/app/core_logic/client.h index e173a26..c5616b7 100644 --- a/src/app/core_logic/client.h +++ b/src/app/core_logic/client.h @@ -8,6 +8,6 @@ #include #include -void chargerClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique); +void ajouter_article(int reference, float poids, float volume, int prixUnitaire); #endif //SAE_101_CLIENT_H diff --git a/src/app/core_logic/responsable.h b/src/app/core_logic/responsable.h index 8bee266..e7b2f67 100644 --- a/src/app/core_logic/responsable.h +++ b/src/app/core_logic/responsable.h @@ -1,3 +1 @@ - - int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], float tPhysique); \ No newline at end of file diff --git a/src/app/core_logic/testResponsable.c b/src/app/core_logic/testResponsable.c index 9759553..0b38a9a 100644 --- a/src/app/core_logic/testResponsable.c +++ b/src/app/core_logic/testResponsable.c @@ -1,12 +1,3 @@ #include #include "responsable.h" #include "../interface/interface_resp.h" - -int main (void) -{ - int tPhysique = 10, tRef[10], tLogique = 0; - float tPoids[10], tVol[10], tPrix[10]; - tLogique = chargementArticles( tRef, tPoids, tVol, tPrix, tPhysique); - affichArticles( tRef, tPoids, tVol, tPrix, tLogique); - return 0; -} \ No newline at end of file diff --git a/src/app/interface/interface_client.c b/src/app/interface/interface_client.c index 193c266..dfbe7a9 100644 --- a/src/app/interface/interface_client.c +++ b/src/app/interface/interface_client.c @@ -17,9 +17,6 @@ void affiche_client(int a){ printf("+-----------------------------------------------------------------+\n"); } -/* -* Sert à lancer le menu et faire choisir l'utilisateur -*/ void menu(int *choix, int jour) { affiche_client(jour); printf("Vous choisissez: "); @@ -34,12 +31,35 @@ void menu(int *choix, int jour) { } } +void ajouter_article(int reference, float poids, float volume, int prixUnitaire){ + + printf("Vous avez choisi d'ajouter un article au panier.\n"); + printf("Veuillez entrer la référence de l'article que vous souhaitez ajouter au panier : "); + scanf("%d", &reference); + printf("Veuillez entrer le poids de l'article que vous souhaitez ajouter au panier : "); + scanf("%f", &poids); + printf("Veuillez entrer le volume de l'article que vous souhaitez ajouter au panier : "); + scanf("%f", &volume); + printf("Veuillez entrer le prix unitaire de l'article que vous souhaitez ajouter au panier : "); + scanf("%d", &prixUnitaire); + printf("L'article a bien été ajouté au panier.\n"); + printf("Voici le récapitulatif du panier : \n"); + printf("Référence : %d \n", reference); + printf("Poids : %f \n", poids); + printf("Volume : %f \n", volume); + printf("Prix unitaire : %d \n", prixUnitaire); +} + void global_client(){ - int choix, jour; + int choix, jour = 0, reference = 0; + float poids = 0.0, volume = 0.0, prixUnitaire = 0.0; menu(&choix, jour); switch (choix) { case 1: - afficherDonneesClient(); + affiche_client(jour); + break; + case 2: + ajouter_article(reference, poids, volume, prixUnitaire); break; default: printf("Veuillez entrer un choix valide ! \n"); diff --git a/src/main.c b/src/main.c index d65ed5f..e08f01c 100644 --- a/src/main.c +++ b/src/main.c @@ -3,6 +3,7 @@ #include "app/interface/interface_client.h" #include "app/interface/interface_resp.h" #include "app/core_logic/client.h" +#include "app/core_logic/responsable.h" int choixInterface(void) { int choix; @@ -27,6 +28,5 @@ int main(){ case 2: global_client(); } - chargerClient(); return 0; } From ffa4a9c32a74cedaad0e28de4658a5911e20a094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=A9o=20Hersan?= Date: Tue, 24 Oct 2023 13:13:28 +0200 Subject: [PATCH 04/22] modifs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathéo Hersan --- .idea/vcs.xml | 2 +- app | Bin 34224 -> 34224 bytes donnee/articles.txt | 3 +-- src/app/interface/interface_client.c | 4 ++-- src/app/interface/interface_client.h | 3 ++- src/app/interface/interface_resp.c | 8 +++----- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app b/app index d63c7bbbd32e1cf3bb664966930adf92e59f9179..b9edbdfd4aa53c8137e8e27797d3925d797554e3 100755 GIT binary patch delta 449 zcmdnc&9niC8khz6{RKTf?6!W`-o|jM;PP(g%@deaY8jVI-r5kXe}_YF>$BQAuWUPHHhjSbk=OXI@EaQCebhDnm3g!;)l%$pMX`Ts@4bd8G^!85!6n z=QoNPr=?{kXE4|RaY9OJZem_aYEgV5#1Mui#`K*0q{N)~AXVFG*%#U`k8NOwM4i z$;vM+NiB*`EGo%N&PinmV`jLM$H2@mrx2(lu_!$?H#M)s5h7X4P?Dcn;h6_ipO%=M z%23J7Fd+@7c0w_bXh;HS$joC{%9xs0%CL%&fi*riBR;hvH5q6@d`4%*j8Yq8)C4|2T%4dL@w*$xr8V52O3=RWHWd11#-wLkaGMa+hX#B@${MVCj zHf`WfL=Df$?agYF_ctd_mTxIkxbXkyqT68~R!m%I)4nf%ebx2T-tvz=F{ar0+?gJ} u>g?~y8(JPHWX!EPbw@6zBv`8E&B^C7U3_1+C(F;X(p$X!-WNd^T|WR3bAnv} diff --git a/donnee/articles.txt b/donnee/articles.txt index fb09fbd..a735975 100644 --- a/donnee/articles.txt +++ b/donnee/articles.txt @@ -2,5 +2,4 @@ 233 10.00 15.00 32.00 272 6.500 10.00 29.99 464 50.0 25.50 60.00 -958 4.75 60.00 32.00 - +958 4.75 60.00 32.00 \ No newline at end of file diff --git a/src/app/interface/interface_client.c b/src/app/interface/interface_client.c index dfbe7a9..99b0d13 100644 --- a/src/app/interface/interface_client.c +++ b/src/app/interface/interface_client.c @@ -31,7 +31,7 @@ void menu(int *choix, int jour) { } } -void ajouter_article(int reference, float poids, float volume, int prixUnitaire){ +void demander_article(int reference, float poids, float volume, int prixUnitaire){ printf("Vous avez choisi d'ajouter un article au panier.\n"); printf("Veuillez entrer la référence de l'article que vous souhaitez ajouter au panier : "); @@ -59,7 +59,7 @@ void global_client(){ affiche_client(jour); break; case 2: - ajouter_article(reference, poids, volume, prixUnitaire); + demander_article(reference, poids, volume, prixUnitaire); break; default: printf("Veuillez entrer un choix valide ! \n"); diff --git a/src/app/interface/interface_client.h b/src/app/interface/interface_client.h index a361055..f7c28b2 100644 --- a/src/app/interface/interface_client.h +++ b/src/app/interface/interface_client.h @@ -2,4 +2,5 @@ void affiche_client(int a); void menu(int *choix, int a); -void global_client(); \ No newline at end of file +void global_client(); +void demander_article(int reference, float poids, float volume, int prixUnitaire); diff --git a/src/app/interface/interface_resp.c b/src/app/interface/interface_resp.c index 650d3fc..0c44fed 100644 --- a/src/app/interface/interface_resp.c +++ b/src/app/interface/interface_resp.c @@ -9,7 +9,7 @@ void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], in for ( i = 0; i < tLogique; ++i) { printf("\t %d %.2f %.2f %.2f\n\n", tRef[i], tPoids[i], tVol[i], tPrix[i]); - } + } } void affichUnArticle(int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique, int val) @@ -42,11 +42,9 @@ void affichUnClient(int tNumClient[], float tCagnotte[], int tSus[], int tLogiqu printf("Client introuvable"); } -void affichUnClients(int tNumClient[], float tCagnotte[], int tSus[], int tLogique, int val) -{ +void affichUnClients(int tNumClient[], float tCagnotte[], int tSus[], int tLogique, int val) { int i; - for ( i = 0; i < tLogique; ++i) - { + for (i = 0; i < tLogique; ++i) { printf("\t %d %.2f %d\n\n", tNumClient[i], tCagnotte[i], tSus[i]); } fprintf(stderr, "Client introuvable"); From 85251c459398fa64dcc07cd47b7740e46a4765d2 Mon Sep 17 00:00:00 2001 From: Yannis DOUMIR FERNANDES Date: Tue, 24 Oct 2023 08:43:34 +0200 Subject: [PATCH 05/22] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/app/core?= =?UTF-8?q?=5Flogic/responsable.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/core_logic/responsable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/core_logic/responsable.c b/src/app/core_logic/responsable.c index 6da8f11..8be0ff7 100644 --- a/src/app/core_logic/responsable.c +++ b/src/app/core_logic/responsable.c @@ -1,7 +1,7 @@ #include #include "responsable.h" -int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], float tPhysique) +int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], int tPhysique) { int i=0, ref; float volume, poids, prix; From cef615520d499bed9b846bb1aaf7baecaa9ebcd5 Mon Sep 17 00:00:00 2001 From: Yannis DOUMIR FERNANDES Date: Tue, 24 Oct 2023 08:45:41 +0200 Subject: [PATCH 06/22] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/app/core?= =?UTF-8?q?=5Flogic/responsable.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/core_logic/responsable.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/core_logic/responsable.c b/src/app/core_logic/responsable.c index 8be0ff7..701a61c 100644 --- a/src/app/core_logic/responsable.c +++ b/src/app/core_logic/responsable.c @@ -10,6 +10,7 @@ int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], if ( fe == NULL) { perror("fopen"); + return -1; } while ( fscanf(fe,"%d %f %f %f", &ref, &poids, &volume, &prix) == 4) { From 97dcabc8801b648230c66b75fa3bf9d65e832425 Mon Sep 17 00:00:00 2001 From: Yannis DOUMIR FERNANDES Date: Tue, 24 Oct 2023 08:59:27 +0200 Subject: [PATCH 07/22] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/app/core?= =?UTF-8?q?=5Flogic/responsable.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/core_logic/responsable.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/app/core_logic/responsable.c b/src/app/core_logic/responsable.c index 701a61c..d6eeefd 100644 --- a/src/app/core_logic/responsable.c +++ b/src/app/core_logic/responsable.c @@ -25,4 +25,23 @@ int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], i++; } return i; +} + +void sauvegadArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], float tLogique) +{ + int i; + FILE * fe; + fe = fopen("articles.txt","w"); + if ( fe == NULL ) + { + perror("fopen"); + return -1; + } + + for ( i = 0; i < tLogique; ++i) + { + fwritef(fe,"%d\t %.2f\t %.2f\t %.2f\n", ); + } + + fclose(fe); } \ No newline at end of file From 8adb4759273e267f1ae24d30a004af698d5ba508 Mon Sep 17 00:00:00 2001 From: Yannis DOUMIR FERNANDES Date: Tue, 24 Oct 2023 08:59:49 +0200 Subject: [PATCH 08/22] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/app/core?= =?UTF-8?q?=5Flogic/responsable.h'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/core_logic/responsable.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/core_logic/responsable.h b/src/app/core_logic/responsable.h index e7b2f67..0e2b8d1 100644 --- a/src/app/core_logic/responsable.h +++ b/src/app/core_logic/responsable.h @@ -1 +1,3 @@ -int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], float tPhysique); \ No newline at end of file +int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], int tPhysique); +void sauvegadArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], float tLogique); +>>>>>>> 8122a29 (Mise à jour de 'src/app/core_logic/responsable.h') From 12158b954fffb4165f867727661378656faeede2 Mon Sep 17 00:00:00 2001 From: Yannis DOUMIR FERNANDES Date: Tue, 24 Oct 2023 09:07:52 +0200 Subject: [PATCH 09/22] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/app/inte?= =?UTF-8?q?rface/interface=5Fclient.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/interface/interface_client.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/app/interface/interface_client.c b/src/app/interface/interface_client.c index 99b0d13..94be817 100644 --- a/src/app/interface/interface_client.c +++ b/src/app/interface/interface_client.c @@ -65,4 +65,16 @@ void global_client(){ printf("Veuillez entrer un choix valide ! \n"); break; } +} + +void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix) +{ + printf("Entrez la ref du nouveaux produit"); + scanf("%d", ref); + printf("Entrez le poids du nouveaux produit"); + scanf("%f", poids); + printf("Entrez le volume du nouveaux produit"); + scanf("%f", volume); + printf("Entrez le prix du nouveaux produit"); + scanf("%f", prix); } \ No newline at end of file From 54b7568a69d4f377b1d97638f4258f19954511f5 Mon Sep 17 00:00:00 2001 From: Yannis DOUMIR FERNANDES Date: Tue, 24 Oct 2023 09:08:14 +0200 Subject: [PATCH 10/22] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/app/inte?= =?UTF-8?q?rface/interface=5Fclient.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/interface/interface_client.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/app/interface/interface_client.c b/src/app/interface/interface_client.c index 94be817..9569dab 100644 --- a/src/app/interface/interface_client.c +++ b/src/app/interface/interface_client.c @@ -67,14 +67,3 @@ void global_client(){ } } -void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix) -{ - printf("Entrez la ref du nouveaux produit"); - scanf("%d", ref); - printf("Entrez le poids du nouveaux produit"); - scanf("%f", poids); - printf("Entrez le volume du nouveaux produit"); - scanf("%f", volume); - printf("Entrez le prix du nouveaux produit"); - scanf("%f", prix); -} \ No newline at end of file From a9a11496b4d4b0a40e1d19cdb9fa2704bfe5bc5d Mon Sep 17 00:00:00 2001 From: Yannis DOUMIR FERNANDES Date: Tue, 24 Oct 2023 09:08:40 +0200 Subject: [PATCH 11/22] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/app/inte?= =?UTF-8?q?rface/interface=5Fresp.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/interface/interface_resp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/app/interface/interface_resp.c b/src/app/interface/interface_resp.c index 0c44fed..a3d51c9 100644 --- a/src/app/interface/interface_resp.c +++ b/src/app/interface/interface_resp.c @@ -49,4 +49,16 @@ void affichUnClients(int tNumClient[], float tCagnotte[], int tSus[], int tLogiq } fprintf(stderr, "Client introuvable"); printf("Client introuvable"); +} + +void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix) +{ + printf("Entrez la ref du nouveaux produit"); + scanf("%d", ref); + printf("Entrez le poids du nouveaux produit"); + scanf("%f", poids); + printf("Entrez le volume du nouveaux produit"); + scanf("%f", volume); + printf("Entrez le prix du nouveaux produit"); + scanf("%f", prix); } \ No newline at end of file From 6548b54a304ab9fa4d5392ec211c957bce0086e3 Mon Sep 17 00:00:00 2001 From: Yannis DOUMIR FERNANDES Date: Tue, 24 Oct 2023 09:09:03 +0200 Subject: [PATCH 12/22] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/app/inte?= =?UTF-8?q?rface/interface=5Fresp.h'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/interface/interface_resp.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/interface/interface_resp.h b/src/app/interface/interface_resp.h index 480a299..d62b642 100644 --- a/src/app/interface/interface_resp.h +++ b/src/app/interface/interface_resp.h @@ -1,4 +1,5 @@ void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique); void affichUnArticle(int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique, int val); void affichUnClient(int tNumClient[], float tCagnotte[], int tSus[], int tLogique, int val); -void affichUnClients(int tNumClient[], float tCagnotte[], int tSus[], int tLogique, int val); \ No newline at end of file +void affichUnClients(int tNumClient[], float tCagnotte[], int tSus[], int tLogique, int val); +void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix); \ No newline at end of file From 25af8e6dbb6cea2c167e4d34b24778997e67e159 Mon Sep 17 00:00:00 2001 From: Yannis DOUMIR FERNANDES Date: Tue, 24 Oct 2023 09:13:03 +0200 Subject: [PATCH 13/22] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/app/inte?= =?UTF-8?q?rface/interface=5Fresp.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/interface/interface_resp.c | 34 +++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/app/interface/interface_resp.c b/src/app/interface/interface_resp.c index a3d51c9..964207a 100644 --- a/src/app/interface/interface_resp.c +++ b/src/app/interface/interface_resp.c @@ -55,10 +55,42 @@ void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix) { printf("Entrez la ref du nouveaux produit"); scanf("%d", ref); + if ( ref < 0 ) + { + while ( ref < 0 ) + { + printf("Entrez un nombre correct !"); + scanf("%d", ref); + } + } printf("Entrez le poids du nouveaux produit"); scanf("%f", poids); + if ( poids < 0 ) + { + while ( poids < 0 ) + { + printf("Entrez un nombre correct !"); + scanf("%d", poids); + } + } printf("Entrez le volume du nouveaux produit"); - scanf("%f", volume); + scanf("%f", poids); + if ( poids < 0 ) + { + while ( poids < 0 ) + { + printf("Entrez un nombre correct !"); + scanf("%d", poids); + } + } printf("Entrez le prix du nouveaux produit"); scanf("%f", prix); + if ( prix < 0 ) + { + while ( prix < 0 ) + { + printf("Entrez un nombre correct !"); + scanf("%d", prix); + } + } } \ No newline at end of file From 2002dc268d6038f8762c066dc925890f37bbf9b7 Mon Sep 17 00:00:00 2001 From: Yannis DOUMIR FERNANDES Date: Tue, 24 Oct 2023 09:13:56 +0200 Subject: [PATCH 14/22] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/app/core?= =?UTF-8?q?=5Flogic/responsable.h'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/core_logic/responsable.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/core_logic/responsable.h b/src/app/core_logic/responsable.h index 0e2b8d1..4230671 100644 --- a/src/app/core_logic/responsable.h +++ b/src/app/core_logic/responsable.h @@ -1,3 +1,5 @@ +#include + int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], int tPhysique); -void sauvegadArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], float tLogique); ->>>>>>> 8122a29 (Mise à jour de 'src/app/core_logic/responsable.h') +void sauvegardArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique); +int ajouterArticle( int tRef[], float tPoids[], float tVol[], float tPrix[], int *tLogique, int tPhysique, int ref, float poids, float volume, float prix); \ No newline at end of file From cef158c1bee6ace046056326d3c0b202b1a756c3 Mon Sep 17 00:00:00 2001 From: Yannis DOUMIR FERNANDES Date: Tue, 24 Oct 2023 09:23:09 +0200 Subject: [PATCH 15/22] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/app/core?= =?UTF-8?q?=5Flogic/responsable.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/core_logic/responsable.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/app/core_logic/responsable.c b/src/app/core_logic/responsable.c index d6eeefd..27bccca 100644 --- a/src/app/core_logic/responsable.c +++ b/src/app/core_logic/responsable.c @@ -44,4 +44,22 @@ void sauvegadArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], f } fclose(fe); +} + +int ajouterArticle( int tRef[], float tPoids[], float tVol[], float tPrix[], int *tLogique, int tPhysique, int ref, float poids, float volume, float prix) +{ + int i = *tLogique; + affichAjoutArticle(&ref, &poids, &volume, &prix); + if ( *tLogique == tPhysique) + { + fprintf(stderr,"Tableau plein !"); + return -2; + } + + // SI on trie pas par ref c'est ca + tRef[i] = ref; + tPoids[i] = poids; + tVol[i] = volume; + tPrix[i] = prix; + } \ No newline at end of file From cdda9a421b1a9650dd5b216268814468ba3e41c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=A9o=20Hersan?= Date: Tue, 24 Oct 2023 10:51:49 +0200 Subject: [PATCH 16/22] fixed some bugs on resp. Added global_resp and added error handling for char MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathéo Hersan --- src/app/core_logic/responsable.c | 17 +++++----- src/app/interface/interface_client.c | 23 ++++++------- src/app/interface/interface_client.h | 5 +++ src/app/interface/interface_resp.c | 50 +++++++++++++++++++++++++--- src/app/interface/interface_resp.h | 4 ++- src/main.c | 4 +-- 6 files changed, 75 insertions(+), 28 deletions(-) diff --git a/src/app/core_logic/responsable.c b/src/app/core_logic/responsable.c index 27bccca..802bd7f 100644 --- a/src/app/core_logic/responsable.c +++ b/src/app/core_logic/responsable.c @@ -1,5 +1,7 @@ #include +#include #include "responsable.h" +#include "../interface/interface_resp.h" int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], int tPhysique) { @@ -27,22 +29,19 @@ int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], return i; } -void sauvegadArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], float tLogique) -{ +void sauvegardArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique){ int i; FILE * fe; - fe = fopen("articles.txt","w"); - if ( fe == NULL ) + fe = fopen("donnee/articles.txt", "w"); + if ( fe == NULL) { perror("fopen"); - return -1; + return; } - - for ( i = 0; i < tLogique; ++i) + for ( i = 0; i < tLogique; i++) { - fwritef(fe,"%d\t %.2f\t %.2f\t %.2f\n", ); + fprintf(fe,"%d %f %f %f\n", tRef[i], tPoids[i], tVol[i], tPrix[i]); } - fclose(fe); } diff --git a/src/app/interface/interface_client.c b/src/app/interface/interface_client.c index 9569dab..f8b8374 100644 --- a/src/app/interface/interface_client.c +++ b/src/app/interface/interface_client.c @@ -17,17 +17,17 @@ void affiche_client(int a){ printf("+-----------------------------------------------------------------+\n"); } -void menu(int *choix, int jour) { +/* +* Sert à lancer le menu et faire choisir l'utilisateur +*/ +void menu_client(int *choix, int jour) { +>>>>>>> 91542d8 (fixed some bugs on resp. Added global_resp and added error handling for char) affiche_client(jour); printf("Vous choisissez: "); - scanf("%d", choix); - - while (*choix < 0) - { + while (scanf("%d", choix) != 1 || *choix < 0 || *choix > 5) { + while (getchar() != '\n'); // Nettoie le tampon d'entrée en cas de saisie invalide affiche_client(jour); - printf("Vous choisissez: "); - printf("Veuillez entrer un choix valide ! \n"); - scanf("%d", choix); + printf("Veuillez entrer un choix valide : "); } } @@ -53,7 +53,7 @@ void demander_article(int reference, float poids, float volume, int prixUnitaire void global_client(){ int choix, jour = 0, reference = 0; float poids = 0.0, volume = 0.0, prixUnitaire = 0.0; - menu(&choix, jour); + menu_client(&choix, jour); switch (choix) { case 1: affiche_client(jour); @@ -62,8 +62,7 @@ void global_client(){ demander_article(reference, poids, volume, prixUnitaire); break; default: - printf("Veuillez entrer un choix valide ! \n"); + printf("Veuillez entrer un choix valide !\n"); break; } -} - +} \ No newline at end of file diff --git a/src/app/interface/interface_client.h b/src/app/interface/interface_client.h index f7c28b2..4503034 100644 --- a/src/app/interface/interface_client.h +++ b/src/app/interface/interface_client.h @@ -1,6 +1,11 @@ #include void affiche_client(int a); +<<<<<<< HEAD void menu(int *choix, int a); void global_client(); void demander_article(int reference, float poids, float volume, int prixUnitaire); +======= +void menu_client(int *choix, int a); +void global_client(); +>>>>>>> 91542d8 (fixed some bugs on resp. Added global_resp and added error handling for char) diff --git a/src/app/interface/interface_resp.c b/src/app/interface/interface_resp.c index 964207a..1b98df7 100644 --- a/src/app/interface/interface_resp.c +++ b/src/app/interface/interface_resp.c @@ -1,6 +1,22 @@ #include #include "interface_resp.h" +void affiche_resp(int a){ + printf("\n"); + printf("+-------------+ \n"); + printf("|| Bonjour ! ||\n") ; + printf("+-------------+ \n"); + printf("\n"); + printf("+-----------------------------------------------------------------+\n"); + printf("|| Que voulez-vous faire ? \t \t \t \t \t || \n"); + printf("||\t1 : Afficher les articles \t \t \t \t || \n"); + printf("||\t2 : Afficher un article \t \t \t \t || \n"); + printf("||\t3 : Afficher un client \t \t \t \t \t || \n"); + printf("||\t4 : Afficher les clients \t \t \t \t || \n"); + printf("||\t5 : Réinitialiser le panier. \t \t \t \t || \n"); + printf("+-----------------------------------------------------------------+\n"); +} + void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique) { int i; @@ -70,7 +86,7 @@ void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix) while ( poids < 0 ) { printf("Entrez un nombre correct !"); - scanf("%d", poids); + scanf("%f", poids); } } printf("Entrez le volume du nouveaux produit"); @@ -80,7 +96,7 @@ void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix) while ( poids < 0 ) { printf("Entrez un nombre correct !"); - scanf("%d", poids); + scanf("%f", poids); } } printf("Entrez le prix du nouveaux produit"); @@ -90,7 +106,33 @@ void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix) while ( prix < 0 ) { printf("Entrez un nombre correct !"); - scanf("%d", prix); + scanf("%f", prix); } } -} \ No newline at end of file +} + + +void menu_resp(int *choix, int jour) { + affiche_resp(jour); + printf("Vous choisissez: "); + while (scanf("%d", choix) != 1 || *choix < 0 || *choix > 5) { + while (getchar() != '\n'); // Nettoie le tampon d'entrée en cas de saisie invalide + affiche_resp(jour); + printf("Veuillez entrer un choix valide : "); + } +} + +void global_resp(){ + int choix, a, tRef[100], tLogique = 0; + float tPoids[100], tVol[100], tPrix[100]; + menu_resp(&choix, a); + switch (choix) { + case 1: + affichArticles(tRef, tPoids, tVol, tPrix, tLogique); + break; + default: + printf("Veuillez entrer un choix valide ! \n"); + break; + } +} + diff --git a/src/app/interface/interface_resp.h b/src/app/interface/interface_resp.h index d62b642..6d7b724 100644 --- a/src/app/interface/interface_resp.h +++ b/src/app/interface/interface_resp.h @@ -2,4 +2,6 @@ void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], in void affichUnArticle(int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique, int val); void affichUnClient(int tNumClient[], float tCagnotte[], int tSus[], int tLogique, int val); void affichUnClients(int tNumClient[], float tCagnotte[], int tSus[], int tLogique, int val); -void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix); \ No newline at end of file +void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix); +void menu_resp(int *choix, int jour); +void global_resp(); diff --git a/src/main.c b/src/main.c index e08f01c..3ec03e6 100644 --- a/src/main.c +++ b/src/main.c @@ -16,7 +16,7 @@ int choixInterface(void) { fprintf(stderr,"Veuillez entrer un choix valide ! \n"); } switch (choix) { - case 1: printf("Vous avez choisit l'interface responsable.\n"); break; + case 1: printf("Vous avez choisit l'interface responsable.\n"); case 2: printf("Vous avez choisit l'interface client.\n"); } return choix; @@ -24,7 +24,7 @@ int choixInterface(void) { int main(){ switch (choixInterface()) { - //case 1: global_resp(); + case 1: global_resp(); case 2: global_client(); } From 0d9eac6e561aaca9cb0a203fcc957d23be65613f Mon Sep 17 00:00:00 2001 From: mahersan Date: Fri, 20 Oct 2023 17:15:19 +0200 Subject: [PATCH 17/22] Added chargerClient --- src/app/core_logic/client.c | 19 +++++++++++++++++++ src/app/core_logic/client.h | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/app/core_logic/client.c b/src/app/core_logic/client.c index 5366f5f..b5cb855 100644 --- a/src/app/core_logic/client.c +++ b/src/app/core_logic/client.c @@ -1,3 +1,22 @@ #include //fonction ajouter un article au panier. +#include "client.h" + +void chargerClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique) +{ + FILE *fic; + int i; + fic = fopen("donnee/client.txt", "r"); + if (fic == NULL) + { + perror("fopen"); + exit(EXIT_FAILURE); + } + + while (fscanf(fic, "%d %f %d", &tNumClient[*tLogique], &tCagnotte[*tLogique], &tSus[*tLogique]) != EOF) + { + (*tLogique)++; + } + fclose(fic); +} diff --git a/src/app/core_logic/client.h b/src/app/core_logic/client.h index c5616b7..e173a26 100644 --- a/src/app/core_logic/client.h +++ b/src/app/core_logic/client.h @@ -8,6 +8,6 @@ #include #include -void ajouter_article(int reference, float poids, float volume, int prixUnitaire); +void chargerClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique); #endif //SAE_101_CLIENT_H From e4d1670166d98abe1fb99ec9f7b3a81e230a53f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=A9o=20Hersan?= Date: Tue, 24 Oct 2023 09:59:58 +0200 Subject: [PATCH 18/22] some modifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathéo Hersan --- src/app/core_logic/client.h | 2 +- src/app/core_logic/responsable.h | 1 - src/app/interface/interface_client.h | 8 +------- src/app/interface/interface_resp.c | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/app/core_logic/client.h b/src/app/core_logic/client.h index e173a26..c5616b7 100644 --- a/src/app/core_logic/client.h +++ b/src/app/core_logic/client.h @@ -8,6 +8,6 @@ #include #include -void chargerClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique); +void ajouter_article(int reference, float poids, float volume, int prixUnitaire); #endif //SAE_101_CLIENT_H diff --git a/src/app/core_logic/responsable.h b/src/app/core_logic/responsable.h index 4230671..50a38c8 100644 --- a/src/app/core_logic/responsable.h +++ b/src/app/core_logic/responsable.h @@ -2,4 +2,3 @@ int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], int tPhysique); void sauvegardArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique); -int ajouterArticle( int tRef[], float tPoids[], float tVol[], float tPrix[], int *tLogique, int tPhysique, int ref, float poids, float volume, float prix); \ No newline at end of file diff --git a/src/app/interface/interface_client.h b/src/app/interface/interface_client.h index 4503034..f091e36 100644 --- a/src/app/interface/interface_client.h +++ b/src/app/interface/interface_client.h @@ -1,11 +1,5 @@ #include void affiche_client(int a); -<<<<<<< HEAD -void menu(int *choix, int a); -void global_client(); -void demander_article(int reference, float poids, float volume, int prixUnitaire); -======= void menu_client(int *choix, int a); -void global_client(); ->>>>>>> 91542d8 (fixed some bugs on resp. Added global_resp and added error handling for char) +void global_client(); \ No newline at end of file diff --git a/src/app/interface/interface_resp.c b/src/app/interface/interface_resp.c index 1b98df7..b73d932 100644 --- a/src/app/interface/interface_resp.c +++ b/src/app/interface/interface_resp.c @@ -123,7 +123,7 @@ void menu_resp(int *choix, int jour) { } void global_resp(){ - int choix, a, tRef[100], tLogique = 0; + int choix, a = 0, tRef[100], tLogique = 0; float tPoids[100], tVol[100], tPrix[100]; menu_resp(&choix, a); switch (choix) { From 7f02f0e351727bb2db9468e666eb295dbade8bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=A9o=20Hersan?= Date: Sat, 28 Oct 2023 17:38:11 +0200 Subject: [PATCH 19/22] added chargement_clients and ajouter_article_au_panier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathéo Hersan --- app | Bin 34224 -> 34928 bytes src/app/core_logic/client.c | 122 ++++++++++++++++++++++++--- src/app/core_logic/client.h | 6 +- src/app/interface/interface_client.c | 53 ++++++------ src/app/interface/interface_client.h | 2 +- 5 files changed, 143 insertions(+), 40 deletions(-) diff --git a/app b/app index b9edbdfd4aa53c8137e8e27797d3925d797554e3..0c6c2f47d445977498eb1de7b3589832b7e63273 100755 GIT binary patch literal 34928 zcmeHQ4RlmRmagtjAPJxd(FlR$g&z|j1Q8I#zm5%x>mTytA_#ArPA6$;x?}&K0cJNd z4XmrqY@R!FbR9efMD2ETCOhhwtjQRsofUU=23AK|$I*u9*q}4VU7fRun#q2*s$S=H zClSt^**#~^sRxx;x9Zldd%wE3s@_X?<(FUl?vLXcvoTzDq;rs(@)+C8G~^hYg0u=r z*H_nGvvT9gH8)Xd_Qe}#7Y(CG&M`3R`nr`H)@4`o_Rj1wCh2?>n~6AdJ>tD9LOF5e z%G;v}W2T)a>WL=1GFKjJ$>fpI^>8G*HJmBRmDhH$kmr{iL|f$*NO{1JU%KuIM?$_p zLx#?_cl=TzFIFHJh_+r<*;EdB!9aM(;9UJ$uN3m6I7YO?DljLn>(RiSzCfMs3)Ba> z{A~Rml=2#7JEC)SvWlc}eUQspQM;~IcinX3S~0p#p%=rQUpaTukrIvlL?m5r2o70E z^vLoyfR|s+Y&*xGuu#1vVyQXQ}7rHm~`3(}9; z_2ITi(tV&iz)0Afk96!?jFnSUS9u)d_!ChOo2^=>mP$HiskL?KM}`Kri1`(fR`1NPau; zfowKM(u5aX(~+n?wU4n@p(GWnOCg{TPzWdl6aoqXg@8gpA)pXY2q**;0tx|zfI>ha zpb$_9Cy)5cq$Jz+jRc9oS`048)kxmMrgp8SU)CX+~-+>;GOp`!1)K zfp)Nd!=ziL8Q(!Z<#6`jNB6PL{(H>2m%%%Z_3tz3W7Cb8nQtjGTFm^0a^o9j{(Q~Y zY35U!ai^I-Qei}pPmOc-hj1U*byWiT8a)pEtt`D`<$VWSqdC=7J-5JKE z;Cmb8R{OpR{xmVL%a#~$F=H@UeH6bUKT?qI?1x_c@mN{k;3C$U@?2mXpQ#x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{WT*42D zOSQ;rkvAc?nEi10L@3;>27_%(F%Ef9yf|#dANE2HHF^BFx1l)@#NDhnstpB_!g^?e zbWnkl^=`vuuZGLMR$TVqDuq}XbC@Slu$jhT4(xmSB&H4~4y1~!ptBP^H0$b%| z$NU)nzz*p31h=WJIHV%o_ePwjl0H*{-RxvNP3YU@rAr8x&PE!AGb#2-sz1VTl+#qD zwM9{PsZBU_Mrlz!Fqh?f_|Y|NbyEx5+N`#E{HRsTQ!m&Z(l%e9(c`mbbhp&XenMs* z-kOklq*IP==}oE2@uBnwX%JV#{9*~G{2)=k^N@>C=*17-lT5$kPV(O6hP=v@_pdNy zoQ1^O_pLN!xQNSimIRF_chUG;Fp%U9Q+|Mait;{F?pbQcKR4wP^Z8GhGW{++^?%Zo znc4pkWYkj=Prt#{F29^5zm_E*%aTuI$)~d9BFNK`i;;=i4CI-}IExQQ)lJ@pY9=#f z5@#xgGt(hr$~XAU8kVjw129VtSsl_Ls5G@q2t3qfgq|`XY?REXQCcYs6+~|Y)Bb$x zjEqP6`1rIzc%}EF^Rz2Z zKm78eAKdqT=}YY==il4ma(?gezZC7<_;GdDFAA>tp)%v0m$lu~7C!x}PtyN++n;`G n`PO%ys(9hU{datD@QP&3tM@*0Md6>H%?rnm^t@2^(a-(|@6kO< diff --git a/src/app/core_logic/client.c b/src/app/core_logic/client.c index b5cb855..40f6a80 100644 --- a/src/app/core_logic/client.c +++ b/src/app/core_logic/client.c @@ -1,22 +1,118 @@ #include -//fonction ajouter un article au panier. #include "client.h" -void chargerClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique) -{ - FILE *fic; - int i; - fic = fopen("donnee/client.txt", "r"); - if (fic == NULL) - { +#define MAX_ARTICLES 100 +#define MAX_CLIENTS 100 + +int charger_clients(int numeros[], float cagnottes[], int suspendues[], int tPhysique) { + int i = 0, numero, suspendue; + float cagnotte; + FILE *fe; + fe = fopen("donnee/client.txt", "r"); + if (fe == NULL) { perror("fopen"); - exit(EXIT_FAILURE); + return -1; + } + while (fscanf(fe, "%d %f %d", &numero, &cagnotte, &suspendue) == 3) { + if (i == tPhysique) { + fprintf(stderr, "Tableau plein"); + break; + } + numeros[i] = numero; + cagnottes[i] = cagnotte; + suspendues[i] = suspendue; + i++; + } + fclose(fe); + return i; +} + + + +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 reference, quantite; + printf("Entrez la référence de l'article : "); + scanf("%d", &reference); + printf("Entrez la quantité : "); + scanf("%d", &quantite); + + int articleIndex = -1; + for (int i = 0; i < nombreArticles; i++) { + if (references[i] == reference) { + articleIndex = i; + break; + } + } + + if (articleIndex == -1) { + printf("Article non trouvé. Veuillez entrer une référence valide.\n"); + return; + } + + float poidsTotal = poids[articleIndex] * quantite; + float volumeTotal = volume[articleIndex] * quantite; + + if (poidsTotal > chargeMaximale) { + printf("Désolé, dépassement de la charge autorisée.\n"); + } else if (volumeTotal > volumeCoffre) { + printf("Désolé, dépassement du volume autorisé.\n"); + } else { + float montantTotal = prixUnitaire[articleIndex] * quantite; + + int clientIndex = -1; + for (int i = 0; i < nombreClients; i++) { + if (numeros[i] == numeroClient) { + clientIndex = i; + break; + } + } + + if (clientIndex != -1) { + cagnottes[clientIndex] += 0.1 * montantTotal; + } + + 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); + } +} + +void supprimer_article_du_panier(int panier[], int *taillePanier) { + int reference; + printf("Interface utilisateur : Entrez la référence de l'article à supprimer : "); + scanf("%d", &reference); + + int articleIndex = -1; + for (int i = 0; i < *taillePanier; i++) { + if (panier[i] == reference) { + articleIndex = i; + break; + } + } + + if (articleIndex == -1) { + printf("Interface utilisateur : Article non trouvé dans le panier. Veuillez entrer une référence valide.\n"); + return; } - while (fscanf(fic, "%d %f %d", &tNumClient[*tLogique], &tCagnotte[*tLogique], &tSus[*tLogique]) != EOF) - { - (*tLogique)++; + for (int i = articleIndex; i < (*taillePanier - 1); i++) { + panier[i] = panier[i + 1]; } - fclose(fic); + + (*taillePanier)--; + + printf("Article supprimé du panier avec succès.\n"); } diff --git a/src/app/core_logic/client.h b/src/app/core_logic/client.h index c5616b7..c3ae5b4 100644 --- a/src/app/core_logic/client.h +++ b/src/app/core_logic/client.h @@ -8,6 +8,10 @@ #include #include -void ajouter_article(int reference, float poids, float volume, int prixUnitaire); +int charger_clients(int numeros[], float cagnottes[], int suspendues[], int tPhysique); +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); +void supprimer_article_du_panier(int panier[], int *taillePanier); #endif //SAE_101_CLIENT_H diff --git a/src/app/interface/interface_client.c b/src/app/interface/interface_client.c index f8b8374..4842cb8 100644 --- a/src/app/interface/interface_client.c +++ b/src/app/interface/interface_client.c @@ -1,10 +1,14 @@ #include "interface_client.h" #include "app/core_logic/client.h" +#include "app/core_logic/responsable.h" -void affiche_client(int a){ +#define MAX_ARTICLES 100 +#define MAX_CLIENTS 100 + +void affiche_client(int a) { printf("\n"); printf("+-------------+ \n"); - printf("|| Bonjour ! ||\n") ; + printf("|| Bonjour ! ||\n"); printf("+-------------+ \n"); printf("\n"); printf("+-----------------------------------------------------------------+\n"); @@ -21,7 +25,6 @@ void affiche_client(int a){ * Sert à lancer le menu et faire choisir l'utilisateur */ void menu_client(int *choix, int jour) { ->>>>>>> 91542d8 (fixed some bugs on resp. Added global_resp and added error handling for char) affiche_client(jour); printf("Vous choisissez: "); while (scanf("%d", choix) != 1 || *choix < 0 || *choix > 5) { @@ -31,38 +34,38 @@ void menu_client(int *choix, int jour) { } } -void demander_article(int reference, float poids, float volume, int prixUnitaire){ +void global_client() { + int choix, jour = 0; + int references[MAX_ARTICLES]; + float poids[MAX_ARTICLES]; + float volume[MAX_ARTICLES]; + float prixUnitaire[MAX_ARTICLES]; + int numeros[MAX_CLIENTS]; + float cagnottes[MAX_CLIENTS]; + int suspendus[MAX_CLIENTS]; // Ajout du tableau des clients suspendus + int nombreArticles, nombreClients; + float volumeCoffre, chargeMaximale; + int numeroClient; - printf("Vous avez choisi d'ajouter un article au panier.\n"); - printf("Veuillez entrer la référence de l'article que vous souhaitez ajouter au panier : "); - scanf("%d", &reference); - printf("Veuillez entrer le poids de l'article que vous souhaitez ajouter au panier : "); - scanf("%f", &poids); - printf("Veuillez entrer le volume de l'article que vous souhaitez ajouter au panier : "); - scanf("%f", &volume); - printf("Veuillez entrer le prix unitaire de l'article que vous souhaitez ajouter au panier : "); - scanf("%d", &prixUnitaire); - printf("L'article a bien été ajouté au panier.\n"); - printf("Voici le récapitulatif du panier : \n"); - printf("Référence : %d \n", reference); - printf("Poids : %f \n", poids); - printf("Volume : %f \n", volume); - printf("Prix unitaire : %d \n", prixUnitaire); -} + nombreArticles = chargementArticles(references, poids, volume, prixUnitaire, MAX_ARTICLES); + nombreClients = charger_clients(numeros, cagnottes, suspendus, MAX_CLIENTS); -void global_client(){ - int choix, jour = 0, reference = 0; - float poids = 0.0, volume = 0.0, prixUnitaire = 0.0; menu_client(&choix, jour); switch (choix) { case 1: affiche_client(jour); break; case 2: - demander_article(reference, poids, volume, prixUnitaire); + // Ajouter la logique d'interface pour ajouter un article au panier ici + ajouter_article_au_panier(numeroClient, references, poids, volume, prixUnitaire, numeros, cagnottes, + suspendus, nombreArticles, nombreClients, volumeCoffre, chargeMaximale); + break; + case 3: + // Ajouter la logique d'interface pour supprimer un article du panier ici + //supprimer_article_du_panier(panier, &taillePanier); break; default: printf("Veuillez entrer un choix valide !\n"); break; } -} \ No newline at end of file +} diff --git a/src/app/interface/interface_client.h b/src/app/interface/interface_client.h index f091e36..ef73ab3 100644 --- a/src/app/interface/interface_client.h +++ b/src/app/interface/interface_client.h @@ -2,4 +2,4 @@ void affiche_client(int a); void menu_client(int *choix, int a); -void global_client(); \ No newline at end of file +void global_client(); From 150af14c084d95f791f2cbddaddf65c49ab61fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=A9o=20Hersan?= Date: Sat, 28 Oct 2023 17:48:54 +0200 Subject: [PATCH 20/22] function add item work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathéo Hersan --- app | Bin 34928 -> 34928 bytes src/app/interface/interface_client.c | 30 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app b/app index 0c6c2f47d445977498eb1de7b3589832b7e63273..2b48d8b2c56ce7f88f817e511b55c34ac032504c 100755 GIT binary patch delta 2778 zcmZ`*4^Wfm8GpZoNKljs*k~-_O9CVi!oLv2fDmU}@yaZ%UH^#FMvRaelbAnUAX_T_j;)r65P|mnP*&Nf(>p4WVHP4kx4N4H4=E z-w+A_7NY1hkI`!UCy>KJWAu;oH`y4y%-bGXjl;`O^b(JsS%W8d8A3bm7Bgzkt%#;BMvMu(2b7Gj%FF#LKRo@rw7Eu|FC&Sv1Q)b=OlBq(@HfO=;o z#$dRXa+U)p88{4nN(i~DP!NVNj3P3;7izgJL^yI8VKsxIas7NY4yU2$Zm#BGw2+Ox zJ802q#%P>8#*w%4gzGGRk`Ls+FA%izIOxTwJw2j9!I%mK;jl9!Dr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*Bd6xt}4qTaa8PBsT$Kgu;KkN!3dHX9(H}$q=zZO`kCkqe5ZhTX_SN$6GldaA;*e zV78Ul*eA5|s-W?$^a>nWc~QWBDDim#x2y0u0p}*;J^}lZal~nXc$3J0!Wz}8#)kxx zil~(~s+D}E^uy>-8L0p{p*lxpk>+G0)kuyc?+09>)&p)<=Sh3DxDTrCYN>d@?vj>5 z!SR~B3NoNJrxeb>u4l{mAlQE&8recXK<=rVuQ~3D?9HgMpF(?>_AzO43@V%CjL$#CWR5n&|>M^|&^`_t>;Ki2E zwS>CNZ?zM_HwRxt@DOOQk4{ud(v2UBoaiXIWUQdRAgO5@$f_jm{xsE0oFsU4&BQVR zd&!!a9n-@y@I3@stYuE3UWF_G>%j5$h>xjAS56-^VL$7!{uv%i$t&qf{e?_?1w1;> zl=b{4Mu8b$U^P*B&pyyeefkv0?%VVXX{-ew2ZgH)Jzg1!$#75%`6S~l>MD_%G*){y zeidBDlk#Qb)dF_q;8g;y&c)?IxR@uy*-Td0i&LhY=SOof9MtTm$-aF~)JeiKS5Y_J zHJK}D_ejVVR*QJ+JsDq&TnX}sjRI+#<{gMRdtPMmI$@xgFZN)ENhaBd&&X( zD#+%hOtG&7@PU^|caxmW$Fq5Um*)$3{xF%-VKc}5 zN7Wo>Z#H(maQ|)Q`AQ|HJ9yrc!tvc4w;?#p;f+G*81L}1p5x#1{6H$luk*YpljC=I zo}l13d&IB_bVDUi#Oc$~+BgKqhx|Ynmu! zY64*PN3E`}NA;=Is#Px*`|F}sEbQGI@ug$_`%K*rX*=qoKi_>^VkN(AO=50`7S&EU zSW`Uk&hR(O^cLg3Jzrm({b@;@|Eua>Htg6{UUhLuw!HL?s{Taep1ED^s@#P)hAfU> zuN~WBZDGz`x<$NO?eckTiHA3aOMf&kI%}#}dD_`Hx#QkJ*}V9xXV+&{M8Dzs2h>u1 AVE_OC diff --git a/src/app/interface/interface_client.c b/src/app/interface/interface_client.c index 4842cb8..060bbac 100644 --- a/src/app/interface/interface_client.c +++ b/src/app/interface/interface_client.c @@ -50,18 +50,44 @@ void global_client() { nombreArticles = chargementArticles(references, poids, volume, prixUnitaire, MAX_ARTICLES); nombreClients = charger_clients(numeros, cagnottes, suspendus, MAX_CLIENTS); + printf("Veuillez saisir la taille disponible du véhicule (en litres) : "); + scanf("%f", &volumeCoffre); + + printf("Veuillez saisir la charge maximale autorisée (en kg) : "); + scanf("%f", &chargeMaximale); + + printf("Veuillez saisir votre numéro de client : "); + scanf("%d", &numeroClient); + + int indexClient = -1; + for (int i = 0; i < nombreClients; i++) { + if (numeros[i] == numeroClient) { + indexClient = i; + break; + } + } + + if (indexClient == -1) { + printf("Client non trouvé. Impossible d'utiliser l'application.\n"); + return; + } + + if (suspendus[indexClient] == 0) { + printf("Le client est suspendu et ne peut pas utiliser l'application.\n"); + return; + } + menu_client(&choix, jour); + switch (choix) { case 1: affiche_client(jour); break; case 2: - // Ajouter la logique d'interface pour ajouter un article au panier ici ajouter_article_au_panier(numeroClient, references, poids, volume, prixUnitaire, numeros, cagnottes, suspendus, nombreArticles, nombreClients, volumeCoffre, chargeMaximale); break; case 3: - // Ajouter la logique d'interface pour supprimer un article du panier ici //supprimer_article_du_panier(panier, &taillePanier); break; default: From 966b93a150412638d9fd03336ae2e384afa23b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=A9o=20Hersan?= Date: Sat, 28 Oct 2023 19:20:21 +0200 Subject: [PATCH 21/22] all function are working MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathéo Hersan --- app | Bin 34928 -> 35008 bytes donnee/panier.txt | 4 -- src/app/core_logic/client.c | 63 +++++++++++++++++++++++++-- src/app/core_logic/client.h | 5 ++- src/app/interface/interface_client.c | 47 ++++++++++++-------- 5 files changed, 91 insertions(+), 28 deletions(-) delete mode 100644 donnee/panier.txt diff --git a/app b/app index 2b48d8b2c56ce7f88f817e511b55c34ac032504c..f78c2934cff643fc1d6fa56749e480efa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+3=8s)*q@aM`}ZUO(;+()z9C zaF(mB+BKO>_zI1~`RJoy}Mq0P4ve_T)eOxSRo7a8q5dabH~qkMTy zqZv+O1KZQc^^~*j8h4g&Ev?@&8B{;tSXWnH^+I|5Eb-xH5DD&7h$n$2KgJfZkS~*$F6YFbrWBF5d+v0B%Cbc z8;c~IBjbTs2|p&|D{&IWREq5f<0Z`Qy3C()Bi zHh2C%w8g7~KDYEVq-Pxn?uya&Tg 5) { - while (getchar() != '\n'); // Nettoie le tampon d'entrée en cas de saisie invalide + while (scanf("%d", choix) != 1 || *choix < 0 || *choix > 9) { + while (getchar() != '\n'); affiche_client(jour); printf("Veuillez entrer un choix valide : "); } @@ -42,10 +43,13 @@ void global_client() { float prixUnitaire[MAX_ARTICLES]; int numeros[MAX_CLIENTS]; float cagnottes[MAX_CLIENTS]; - int suspendus[MAX_CLIENTS]; // Ajout du tableau des clients suspendus + int suspendus[MAX_CLIENTS]; int nombreArticles, nombreClients; float volumeCoffre, chargeMaximale; int numeroClient; + int quantites[MAX_ARTICLES]; + int panier[MAX_ARTICLES]; + int taillePanier = 0; nombreArticles = chargementArticles(references, poids, volume, prixUnitaire, MAX_ARTICLES); nombreClients = charger_clients(numeros, cagnottes, suspendus, MAX_CLIENTS); @@ -77,21 +81,26 @@ void global_client() { return; } - menu_client(&choix, jour); + do{ + menu_client(&choix, jour); - switch (choix) { - case 1: - affiche_client(jour); - break; - case 2: - ajouter_article_au_panier(numeroClient, references, poids, volume, prixUnitaire, numeros, cagnottes, - suspendus, nombreArticles, nombreClients, volumeCoffre, chargeMaximale); - break; - case 3: - //supprimer_article_du_panier(panier, &taillePanier); - break; - default: - printf("Veuillez entrer un choix valide !\n"); - break; - } + switch (choix) { + case 1: + affiche_recap_panier(panier, taillePanier, references, poids, volume, prixUnitaire, quantites); + break; + case 2: + ajouter_article_au_panier(numeroClient, references, poids, volume, prixUnitaire, numeros, cagnottes, + suspendus, nombreArticles, nombreClients, volumeCoffre, chargeMaximale, panier, quantites, &taillePanier); + break; + case 3: + supprimer_article_du_panier(panier, &taillePanier); + break; + case 9: + printf("Au revoir !\n"); + return; + default: + printf("Veuillez entrer un choix valide !\n"); + break; + } + }while(choix != 9); } From d966c1bc35066a65011aa9b5be4a8b0f613f0db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=A9o=20Hersan?= Date: Sat, 28 Oct 2023 19:41:40 +0200 Subject: [PATCH 22/22] basket summary really works MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathéo Hersan --- app | Bin 35008 -> 35008 bytes donnee/articles.txt | 2 +- src/app/core_logic/client.c | 11 +++++------ src/app/interface/interface_client.c | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app b/app index f78c2934cff643fc1d6fa56749e480efa4e67313..0458afb0ceb6a42609fa835a3d51c5eb9a70a1e2 100755 GIT binary patch delta 2033 zcmZ`)dr(wW7(eGOk6jUjcg{nHp+7GakwPYF%3=-5u^l( zJSS}*jZTOVv1MVR$H+c^9To+#Dv|wNp=7m!l&~e0X8U|LnadUlesKWFhfcXKeiN?9 ztHP70o`I0pM2e-yrgbCYz4_~qe>%Wvy$3VA#yT_~} zs&f&{Xf?4zp&}9Af=)$N*)8fl+vH(^(e0?M!jRx5vW8b+BxBn6hJ zOp*w8g0I=W6iQSV7>Of9sG}rP4pj6s+n+$bx}IJh))*wcyml4hG$z~wg&JS+IjXf) zZl0+P^nyl>KR(H-;muV2eQwT|?_w9S=tu*b6m6bicZc6asw+r6U~Q~)|8v|*SgrMx z?t6~Ahn*X~?Ky59)&IAORz2AOV_ILF4R&oTPMyaqAT2OKY@%6qwNR|_!Ukvx%w=31 zz$qx0kvPyB@dG>ook2SMHGCJ8g1-Pouoho}q~K(H8a@h6#Px6`xCOrj`8qA$35Ru6 ziewR2&=zLyp*NO?Ee!SCr7dBb8UsdsJ@$b?J>ZA1F+_`}p*$o3-+{i6L_7$yAuDkg zq=kM=pM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mLY}5^KJGv3Cg5sE^cmedqY{Ic%h}B`Wb$RSGjBi6} z+&nx4C*r~|ea_-^lGB)9uq2+G6mWAqu|m-FHbowAUf?YWg&aH$aJDK7Ifv3}NnP5o*qbpA2vLF|xJ}_8zp<=XZO# zBY#W1totLYkFf=dbx$W-SgG0CnJ_s8=UF?`S7dnF<{}Ylodv#IWbqGYQ~Y=i9U3z5 zCX|4fjPi=&!jg4JZ!Rfb_hto35uxidsQ&RbEe4Nsiz#$K)0SjUM;3)0OW?|u zS-Pi*6!$Mgh$-Zz?qSN;Z7M@840RV#tu=uTb}-h3dvq_N&<3mO*5m6iSf^!fxxsjy zs%E~L`!Yn+t2ULk-WtmBRGwFaaXgFX4N8vZ^L(?4<0U*7zBJW54>5519-faVINr|j zwPPVmI(q%5fI6KNI{>A7+sARXtxV z&~mO+o+s-#p3QTcHKSpPsD|AYd*C%?Wk?*kvUO_D(15DiE#Hv3SDyOAxs}`Wvb=)3 zmMi76e9!6snlrr5cxA(c8`)v|c5LW_n62W;1z+C3wA~qa?cygxg}yCalC<>Pn6Hj4 zOkU-EeVI91dHmUc|IC9%?dqD{BWFWWa{5=CBwzo+G?rz)d-LrWU-is@-!6`B-B?@K s8QuLED7V)t<44Ck0(wfX+01?c`-0BV>D>Cq+&4bA4i&JFaQ7m diff --git a/donnee/articles.txt b/donnee/articles.txt index a735975..6231299 100644 --- a/donnee/articles.txt +++ b/donnee/articles.txt @@ -2,4 +2,4 @@ 233 10.00 15.00 32.00 272 6.500 10.00 29.99 464 50.0 25.50 60.00 -958 4.75 60.00 32.00 \ No newline at end of file +958 4.75 60.00 32.00 diff --git a/src/app/core_logic/client.c b/src/app/core_logic/client.c index fc2280a..92a8936 100644 --- a/src/app/core_logic/client.c +++ b/src/app/core_logic/client.c @@ -141,7 +141,7 @@ void affiche_recap_panier(int panier[], int taillePanier, int references[], floa for (int i = 0; i < taillePanier; i++) { int reference = panier[i]; int articleIndex = -1; - for (int j = 0; j < taillePanier; j++) { + for (int j = 0; j < MAX_ARTICLES; j++) { if (references[j] == reference) { articleIndex = j; break; @@ -158,14 +158,13 @@ void affiche_recap_panier(int panier[], int taillePanier, int references[], floa float prixArticle = prixUnitaire[articleIndex]; int quantite = quantites[i]; - printf("%d\t %d\t %.2f\t %.2f\t %.2f\t %.2f\t %.2f\t %.2f\n", reference, quantite, poidsArticle, volumeArticle, - prixArticle, poidsArticle, volumeArticle, prixArticle); + prixArticle, poidsArticle * quantite, volumeArticle * quantite, prixArticle * quantite); - poidsTotal += poidsArticle; - volumeTotal += volumeArticle; - montantTotal += prixArticle; + poidsTotal += poidsArticle * quantite; + volumeTotal += volumeArticle * quantite; + montantTotal += prixArticle * quantite; } printf("Prix total à payer: %.2f euros\n", montantTotal); diff --git a/src/app/interface/interface_client.c b/src/app/interface/interface_client.c index 55ee3d5..6e63392 100644 --- a/src/app/interface/interface_client.c +++ b/src/app/interface/interface_client.c @@ -76,7 +76,7 @@ void global_client() { return; } - if (suspendus[indexClient] == 0) { + if (suspendus[indexClient] == 1) { printf("Le client est suspendu et ne peut pas utiliser l'application.\n"); return; }