|
|
@ -41,6 +41,170 @@ void menu_client(int *choix) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Ajoute un article au panier du client.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Cette fonction permet d'ajouter un article au panier du client.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param numeroClient - Numéro du client.
|
|
|
|
|
|
|
|
* @param references - Tableau des références des articles.
|
|
|
|
|
|
|
|
* @param poids - Tableau des poids des articles.
|
|
|
|
|
|
|
|
* @param volume - Tableau des volumes des articles.
|
|
|
|
|
|
|
|
* @param prixUnitaire - Tableau des prix unitaires des articles.
|
|
|
|
|
|
|
|
* @param numeros - Tableau des numéros de clients.
|
|
|
|
|
|
|
|
* @param cagnottes - Tableau des cagnottes des clients.
|
|
|
|
|
|
|
|
* @param suspendues - Tableau des états de suspension des clients.
|
|
|
|
|
|
|
|
* @param nombreArticles - Nombre d'articles disponibles.
|
|
|
|
|
|
|
|
* @param nombreClients - Nombre de clients.
|
|
|
|
|
|
|
|
* @param volumeCoffre - Volume total du coffre.
|
|
|
|
|
|
|
|
* @param chargeMaximale - Charge maximale du coffre.
|
|
|
|
|
|
|
|
* @param panier - Tableau des références des articles dans le panier.
|
|
|
|
|
|
|
|
* @param quantites - Tableau des quantités de chaque article dans le panier.
|
|
|
|
|
|
|
|
* @param taillePanier - Taille du panier.
|
|
|
|
|
|
|
|
* @param budget - Budget du client.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
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 panier[], int quantites[], int *taillePanier, float budget) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int reference, quantite, articleIndex;
|
|
|
|
|
|
|
|
float poidsTotal, montantTotal, volumeTotal, depassementCharge = 0, depassementVolume, depassementBudget = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
|
|
|
|
printf("Entrez la référence de l'article : ");
|
|
|
|
|
|
|
|
while (scanf("%d", &reference) != 1) {
|
|
|
|
|
|
|
|
while (getchar() != '\n');
|
|
|
|
|
|
|
|
printf("ERREUR : Veuillez entrer une référence valide (nombre) : ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while (getchar() != '\n');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
articleIndex = trouver_index_article(reference, references, nombreArticles);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (articleIndex == -1) {
|
|
|
|
|
|
|
|
printf("ERREUR : Article non trouvé. Veuillez entrer une référence valide.\n");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("Entrez la quantité : ");
|
|
|
|
|
|
|
|
while (scanf("%d", &quantite) != 1) {
|
|
|
|
|
|
|
|
while (getchar() != '\n');
|
|
|
|
|
|
|
|
printf("ERREUR : Veuillez entrer une quantité valide (nombre) : ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while (getchar() != '\n');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
poidsTotal = poids[articleIndex] * quantite;
|
|
|
|
|
|
|
|
volumeTotal = volume[articleIndex] * quantite;
|
|
|
|
|
|
|
|
montantTotal = prixUnitaire[articleIndex] * quantite;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (poidsTotal > chargeMaximale) {
|
|
|
|
|
|
|
|
depassementCharge = poidsTotal - chargeMaximale;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (volumeTotal > volumeCoffre) {
|
|
|
|
|
|
|
|
depassementVolume = volumeTotal - volumeCoffre;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (budget > 0 && montantTotal > budget) {
|
|
|
|
|
|
|
|
depassementBudget = montantTotal - budget;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (depassementCharge || depassementVolume || depassementBudget) {
|
|
|
|
|
|
|
|
printf("Attention : \n");
|
|
|
|
|
|
|
|
if (depassementCharge) {
|
|
|
|
|
|
|
|
printf("\tDépassement de la charge autorisée de %.2f kg \n", depassementCharge);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (depassementVolume) {
|
|
|
|
|
|
|
|
printf("\tDépassement du volume autorisé de %.2f litres \n", depassementVolume);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (depassementBudget) {
|
|
|
|
|
|
|
|
printf("\tDépassement du budget autorisé de %.2f euros \n", depassementBudget);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
float montantTotal = prixUnitaire[articleIndex] * quantite;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int clientIndex = trouver_index_client(numeroClient, numeros, nombreClients);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (clientIndex != -1) {
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Supprime un article du panier du client.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Cette fonction permet de supprimer un article du panier du client.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param panier - Tableau des références des articles dans le panier.
|
|
|
|
|
|
|
|
* @param quantites - Tableau des quantités de chaque article dans le panier.
|
|
|
|
|
|
|
|
* @param taillePanier - Taille du panier.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void supprimer_article_du_panier(int panier[], int quantites[], int *taillePanier, float cagnottes[], int numeroClient, int numeros[], int nombreClients, int references[], float prixUnitaire[]) {
|
|
|
|
|
|
|
|
int reference;
|
|
|
|
|
|
|
|
printf("Entrez la référence de l'article à supprimer : ");
|
|
|
|
|
|
|
|
while (scanf("%d", &reference) != 1) {
|
|
|
|
|
|
|
|
while (getchar() != '\n');
|
|
|
|
|
|
|
|
printf("ERREUR : Veuillez entrer une référence valide (nombre) : ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while (getchar() != '\n');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int articleIndex = trouver_index_article(reference, references, MAX_ARTICLES);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (articleIndex == -1) {
|
|
|
|
|
|
|
|
printf("Article non trouvé dans le panier. Veuillez entrer une référence valide.\n");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int quantite = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < *taillePanier; i++) {
|
|
|
|
|
|
|
|
if (panier[i] == reference) {
|
|
|
|
|
|
|
|
quantite = quantites[i];
|
|
|
|
|
|
|
|
for (int j = i; j < *taillePanier - 1; j++) {
|
|
|
|
|
|
|
|
panier[j] = panier[j + 1];
|
|
|
|
|
|
|
|
quantites[j] = quantites[j + 1];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(*taillePanier)--;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int clientIndex = trouver_index_client(numeroClient, numeros, nombreClients);
|
|
|
|
|
|
|
|
if (clientIndex != -1) {
|
|
|
|
|
|
|
|
float montantTotal = prixUnitaire[articleIndex] * quantite;
|
|
|
|
|
|
|
|
cagnottes[clientIndex] -= 0.1 * montantTotal; // Retirer 10% du montant
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("Article supprimé du panier avec succès.\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief Affiche le récapitulatif du panier.
|
|
|
|
* @brief Affiche le récapitulatif du panier.
|
|
|
@ -141,7 +305,8 @@ void global_client() {
|
|
|
|
suspendus, nombreArticles, nombreClients, volumeCoffre, chargeMaximale, panier, quantites, &taillePanier, budget);
|
|
|
|
suspendus, nombreArticles, nombreClients, volumeCoffre, chargeMaximale, panier, quantites, &taillePanier, budget);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 3:
|
|
|
|
supprimer_article_du_panier(panier, quantites, &taillePanier);
|
|
|
|
//supprimer_article_du_panier(panier, quantites, &taillePanier, prixUnitaire, numeroClient, cagnottes);
|
|
|
|
|
|
|
|
supprimer_article_du_panier(panier, quantites, &taillePanier, cagnottes, numeroClient, numeros, nombreClients, references, prixUnitaire);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 4:
|
|
|
|
modifier_quantite_article_panier(panier, quantites, &taillePanier);
|
|
|
|
modifier_quantite_article_panier(panier, quantites, &taillePanier);
|
|
|
|