diff --git a/app b/app index d3b3513..ce451de 100755 Binary files a/app and b/app differ diff --git a/src/app/core_logic/responsable.c b/src/app/core_logic/responsable.c index 9f16611..ba7dc6e 100644 --- a/src/app/core_logic/responsable.c +++ b/src/app/core_logic/responsable.c @@ -42,7 +42,7 @@ void sauvegardArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], for ( i = 0; i < tLogique; i++) { - fprintf(fe,"\t %d\t %f\t %f\t %f\n", tRef[i], tPoids[i], tVol[i], tPrix[i]); + fprintf(fe,"\t %d\t %.2f\t %.2f\t %.2f\n", tRef[i], tPoids[i], tVol[i], tPrix[i]); } fclose(fe); } @@ -56,13 +56,11 @@ int ajouterArticle( int tRef[], float tPoids[], float tVol[], float tPrix[], int fprintf(stderr,"Tableau plein !"); return -2; } - printf("%d\n", *tLogique); tRef[i] = ref; tPoids[i] = poids; tVol[i] = volume; tPrix[i] = prix; (*tLogique)++; - printf("%d\n", *tLogique); return 0; } @@ -108,4 +106,17 @@ void modifierArticle(int tRef[], float tPoids[], float tVol[], float tPrix[], in tVol[index] = volume; tPrix[index] = prix; +} + +void ajouterClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique, int tPhysique) +{ + int numC = 0; + affichAjoutClient(tNumClient, *tLogique, &numC); + + tNumClient[*tLogique] = numC; + tCagnotte[*tLogique] = 0; + tSus[*tLogique] = 0; + (*tLogique)++; + return; + } \ No newline at end of file diff --git a/src/app/core_logic/responsable.h b/src/app/core_logic/responsable.h index 66b520a..b2c6f70 100644 --- a/src/app/core_logic/responsable.h +++ b/src/app/core_logic/responsable.h @@ -5,4 +5,5 @@ void sauvegardArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], int ajouterArticle( int tRef[], float tPoids[], float tVol[], float tPrix[], int *tLogique, int tPhysique, int ref, float poids, float volume, float prix); void rechercheRefArticle(int tRef[], int ref, int *index, int tLogique); void supprimerArticle(int tRef[], float tPoids[], float tVol[], float tPrix[], int *tLogique); -void modifierArticle(int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique); \ No newline at end of file +void modifierArticle(int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique); +void ajouterClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique, int tPhysique); \ No newline at end of file diff --git a/src/app/interface/interface_resp.c b/src/app/interface/interface_resp.c index 198aafd..f7c7cf3 100644 --- a/src/app/interface/interface_resp.c +++ b/src/app/interface/interface_resp.c @@ -23,6 +23,7 @@ void affiche_resp(void){ printf("||\t5 : Ajouter un article \t \t \t \t \t || \n"); printf("||\t6 : Supprimer un article \t \t \t \t || \n"); printf("||\t7 : Modifier un article \t \t \t \t || \n"); + printf("||\t8 : Ajouter un client\t \t \t \t \t || \n"); printf("||\t9 : Quittez. \t \t \t \t \t \t || \n"); printf("+-----------------------------------------------------------------+\n"); } @@ -183,6 +184,24 @@ void affichModifierArticle(int *ref, float *poids, float *volume, float *prix) } } +void affichAjoutClient(int tNumClient[], int tLogique, int *numC) +{ + printf("\t Veuillez entrer le numéro du nouveau client\n"); + while(scanf("%d", numC) != 1 || *numC <= 0) + { + printf("Entrez un numéro valide !\n"); + while(getchar() != '\n'); + } + for ( int i = 0 ; i < tLogique; ++i) + { + if ( *numC == tNumClient[i] ) + { + fprintf(stderr,"\t Client déjà existant.\n"); + return; + } + } +} + /* void menu_resp(int *choix, int jour) { affiche_resp(); @@ -248,7 +267,7 @@ void global_resp(){ modifierArticle(tRef, tPoids, tVol, tPrix, tLogArticle); break; case 8: - printf("Ouai tkt ^^'\n"); + ajouterClient(tNumClient, tCagnotte, tSus, &tLogClient, MAX_CLIENTS); break; case 9: sauvegardArticles(tRef, tPoids, tVol, tPrix, tLogArticle); diff --git a/src/app/interface/interface_resp.h b/src/app/interface/interface_resp.h index 8bf6f7c..6b9826c 100644 --- a/src/app/interface/interface_resp.h +++ b/src/app/interface/interface_resp.h @@ -6,6 +6,7 @@ void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix); void affichSupprimerArticle(int *ref); void affichModifierArticle(int *ref, float *poids, float *volume, float *prix); void problemRechercheArticle(); +void affichAjoutClient(int tNumClient[], int tLogique, int *numC); void menu_resp(int *choix); void global_resp(); void affiche_resp(void); \ No newline at end of file