diff --git a/app b/app deleted file mode 100755 index 893f445..0000000 Binary files a/app and /dev/null differ diff --git a/donnee/articles.txt b/donnee/articles.txt index 6231299..9ed2f12 100644 --- a/donnee/articles.txt +++ b/donnee/articles.txt @@ -1,5 +1,3 @@ -101 2.250 2.50 15.75 -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 + 464 50.000000 25.500000 60.000000 + 958 4.750000 60.000000 32.000000 + 101 1.000000 1.000000 1.000000 diff --git a/src/app/core_logic/responsable.c b/src/app/core_logic/responsable.c index e106afa..ba7dc6e 100644 --- a/src/app/core_logic/responsable.c +++ b/src/app/core_logic/responsable.c @@ -36,18 +36,17 @@ void sauvegardArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], fe = fopen("donnee/articles.txt", "w"); if ( fe == NULL) { - perror("fopen"); + fprintf(stderr, "\n Problème ouverture ficher\n"); return; } + for ( i = 0; i < tLogique; i++) { - fprintf(fe,"%d %f %f %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); } - - 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; @@ -57,14 +56,12 @@ int ajouterArticle( int tRef[], float tPoids[], float tVol[], float tPrix[], int 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; + (*tLogique)++; return 0; - } void rechercheRefArticle(int tRef[], int ref, int *index, int tLogique) @@ -77,19 +74,18 @@ void rechercheRefArticle(int tRef[], int ref, int *index, int tLogique) return; } } + fprintf(stderr, "\t Article non trouvé.\n"); *index = -1; return; } - - void supprimerArticle(int tRef[], float tPoids[], float tVol[], float tPrix[], int *tLogique) { int ref, index; affichSupprimerArticle(&ref); rechercheRefArticle(tRef, ref, &index, *tLogique); - for( int i = index; i< *tLogique-1; ++i) + for( int i = index; i < *tLogique-1; ++i) { tRef[i] = tRef[i+1]; tPoids[i] = tPoids[i+1]; @@ -110,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/main.c b/src/main.c index 9db7ce4..3910ccf 100644 --- a/src/main.c +++ b/src/main.c @@ -36,4 +36,4 @@ int main(){ } return 0; -} +} \ No newline at end of file