all function are working

Signed-off-by: Mathéo Hersan <matheohersan@MacBook-Pro-de-Matheo.local>
pull/2/head
Mathéo Hersan 2 years ago
parent 150af14c08
commit 966b93a150
No known key found for this signature in database
GPG Key ID: 4EF19C64D78EC91B

BIN
app

Binary file not shown.

@ -1,4 +0,0 @@
32
660
5079
8043

@ -32,7 +32,7 @@ int charger_clients(int numeros[], float cagnottes[], int suspendues[], int tPhy
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) {
float volumeCoffre, float chargeMaximale, int panier[], int quantites[], int *taillePanier) {
int reference, quantite;
printf("Entrez la référence de l'article : ");
scanf("%d", &reference);
@ -52,6 +52,13 @@ void ajouter_article_au_panier(int numeroClient, int references[], float poids[]
return;
}
for (int i = 0; i < *taillePanier; i++) {
if (panier[i] == reference) {
printf("Cet article est déjà dans le panier.\n");
return;
}
}
float poidsTotal = poids[articleIndex] * quantite;
float volumeTotal = volume[articleIndex] * quantite;
@ -74,6 +81,16 @@ void ajouter_article_au_panier(int numeroClient, int references[], float poids[]
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");
@ -92,7 +109,7 @@ void ajouter_article_au_panier(int numeroClient, int references[], float poids[]
void supprimer_article_du_panier(int panier[], int *taillePanier) {
int reference;
printf("Interface utilisateur : Entrez la référence de l'article à supprimer : ");
printf("Entrez la référence de l'article à supprimer : ");
scanf("%d", &reference);
int articleIndex = -1;
@ -104,7 +121,7 @@ void supprimer_article_du_panier(int panier[], int *taillePanier) {
}
if (articleIndex == -1) {
printf("Interface utilisateur : Article non trouvé dans le panier. Veuillez entrer une référence valide.\n");
printf("Article non trouvé dans le panier. Veuillez entrer une référence valide.\n");
return;
}
@ -116,3 +133,43 @@ void supprimer_article_du_panier(int panier[], int *taillePanier) {
printf("Article supprimé du panier avec succès.\n");
}
void affiche_recap_panier(int panier[], int taillePanier, int references[], float poids[], float volume[],
float prixUnitaire[], int quantites[]) {
printf("Réf Qté Poids Vol PrixU PoidsTot VolTot PrixTot\n");
float poidsTotal = 0, volumeTotal = 0, montantTotal = 0;
for (int i = 0; i < taillePanier; i++) {
int reference = panier[i];
int articleIndex = -1;
for (int j = 0; j < taillePanier; j++) {
if (references[j] == reference) {
articleIndex = j;
break;
}
}
if (articleIndex == -1) {
printf("Article non trouvé. Veuillez entrer une référence valide.\n");
return;
}
float poidsArticle = poids[articleIndex];
float volumeArticle = volume[articleIndex];
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);
poidsTotal += poidsArticle;
volumeTotal += volumeArticle;
montantTotal += prixArticle;
}
printf("Prix total à payer: %.2f euros\n", montantTotal);
printf("Volume utilise : %.2f litres\n", volumeTotal);
printf("Charge Actuelle: %.2f kg\n", poidsTotal);
}

@ -11,7 +11,8 @@
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);
float volumeCoffre, float chargeMaximale, int panier[], int quantites[], int *taillePanier);
void supprimer_article_du_panier(int panier[], int *taillePanier);
void affiche_recap_panier(int panier[], int taillePanier, int references[], float poids[], float volume[],
float prixUnitaire[], int quantites[]);
#endif //SAE_101_CLIENT_H

@ -18,6 +18,7 @@ void affiche_client(int a) {
printf("||\t3 : Supprimer un article du panier. \t \t \t || \n");
printf("||\t4 : Modifier la quantité d'un article du panier. \t || \n");
printf("||\t5 : Réinitialiser le panier. \t \t \t \t || \n");
printf("||\t9 : Quitter. \t \t \t \t \t \t || \n");
printf("+-----------------------------------------------------------------+\n");
}
@ -27,8 +28,8 @@ void affiche_client(int a) {
void menu_client(int *choix, int jour) {
affiche_client(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
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);
}

Loading…
Cancel
Save