diff --git a/app b/app new file mode 100755 index 0000000..d63c7bb Binary files /dev/null and b/app differ 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; }