added all the verifications

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

BIN
app

Binary file not shown.

@ -34,10 +34,20 @@ void ajouter_article_au_panier(int numeroClient, int references[], float poids[]
int numeros[], float cagnottes[], int suspendues[], int nombreArticles, int nombreClients, int numeros[], float cagnottes[], int suspendues[], int nombreArticles, int nombreClients,
float volumeCoffre, float chargeMaximale, int panier[], int quantites[], int *taillePanier) { float volumeCoffre, float chargeMaximale, int panier[], int quantites[], int *taillePanier) {
int reference, quantite; int reference, quantite;
printf("Entrez la référence de l'article : "); printf("Entrez la référence de l'article : ");
scanf("%d", &reference); while (scanf("%d", &reference) != 1) {
while (getchar() != '\n');
printf("ERREUR : Veuillez entrer une référence valide (nombre) : ");
}
while (getchar() != '\n');
printf("Entrez la quantité : "); printf("Entrez la quantité : ");
scanf("%d", &quantite); while (scanf("%d", &quantite) != 1) {
while (getchar() != '\n');
printf("ERREUR : Veurillez entrer une quantité valide (nombre) : ");
}
while (getchar() != '\n');
int articleIndex = -1; int articleIndex = -1;
for (int i = 0; i < nombreArticles; i++) { for (int i = 0; i < nombreArticles; i++) {
@ -110,7 +120,11 @@ void ajouter_article_au_panier(int numeroClient, int references[], float poids[]
void supprimer_article_du_panier(int panier[], int quantites[], int *taillePanier) { void supprimer_article_du_panier(int panier[], int quantites[], int *taillePanier) {
int reference; int reference;
printf("Entrez la référence de l'article à supprimer : "); printf("Entrez la référence de l'article à supprimer : ");
scanf("%d", &reference); while (scanf("%d", &reference) != 1) {
while (getchar() != '\n');
printf("ERREUR : Veuillez entrer une référence valide (nombre) : ");
}
while (getchar() != '\n');
int articleIndex = -1; int articleIndex = -1;
for (int i = 0; i < *taillePanier; i++) { for (int i = 0; i < *taillePanier; i++) {
@ -175,8 +189,13 @@ void affiche_recap_panier(int panier[], int taillePanier, int references[], floa
void modifier_quantite_article_panier(int panier[], int quantites[], int *taillePanier) { void modifier_quantite_article_panier(int panier[], int quantites[], int *taillePanier) {
int reference, quantite; int reference, quantite;
printf("Entrez la référence de l'article à modifier : ");
scanf("%d", &reference); 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'); // Nettoyer le tampon d'entrée
int articleIndex = -1; int articleIndex = -1;
for (int i = 0; i < *taillePanier; i++) { for (int i = 0; i < *taillePanier; i++) {
@ -191,8 +210,12 @@ void modifier_quantite_article_panier(int panier[], int quantites[], int *taille
return; return;
} }
printf("Entrez la nouvelle quantité : "); printf("Entrez la quantité : ");
scanf("%d", &quantite); while (scanf("%d", &quantite) != 1) {
while (getchar() != '\n');
printf("ERREUR : Veuillez entrer une quantité valide (nombre) : ");
}
while (getchar() != '\n');
quantites[articleIndex] = quantite; quantites[articleIndex] = quantite;

@ -30,8 +30,7 @@ void menu_client(int *choix, int jour) {
printf("Vous choisissez: "); printf("Vous choisissez: ");
while (scanf("%d", choix) != 1 || *choix < 0 || *choix > 9) { while (scanf("%d", choix) != 1 || *choix < 0 || *choix > 9) {
while (getchar() != '\n'); while (getchar() != '\n');
affiche_client(jour); printf("ERREUR : Veuillez entrer un choix valide : ");
printf("Veuillez entrer un choix valide : ");
} }
} }
@ -55,13 +54,22 @@ void global_client() {
nombreClients = charger_clients(numeros, cagnottes, suspendus, MAX_CLIENTS); nombreClients = charger_clients(numeros, cagnottes, suspendus, MAX_CLIENTS);
printf("Veuillez saisir la taille disponible du véhicule (en litres) : "); printf("Veuillez saisir la taille disponible du véhicule (en litres) : ");
scanf("%f", &volumeCoffre); while (scanf("%f", &volumeCoffre) != 1 || volumeCoffre <= 0) {
while (getchar() != '\n');
printf("ERREUR : Veuillez entrer une taille de coffre valide (en litres) : ");
}
printf("Veuillez saisir la charge maximale autorisée (en kg) : "); printf("Veuillez saisir la charge maximale autorisée (en kg) : ");
scanf("%f", &chargeMaximale); while (scanf("%f", &chargeMaximale) != 1 || chargeMaximale <= 0) {
while (getchar() != '\n');
printf("ERREUR : Veuillez entrer une charge maximale valide (en kg) : ");
}
printf("Veuillez saisir votre numéro de client : "); printf("Veuillez saisir votre numéro de client : ");
scanf("%d", &numeroClient); while (scanf("%d", &numeroClient) != 1) {
while (getchar() != '\n');
printf("ERREUR : Veuillez entrer un numéro de client valide : ");
}
int indexClient = -1; int indexClient = -1;
for (int i = 0; i < nombreClients; i++) { for (int i = 0; i < nombreClients; i++) {

Loading…
Cancel
Save