Amélioration de la fonction global

doc
Rémi LAVERGNE 1 year ago
parent 654ae75994
commit 4f37861280

@ -10,7 +10,14 @@ int displayMenu(void)
+var choice: choix de l'action +var choice: choix de l'action
*/ */
int choice; int choice;
//TODO > Clear screen
printf("\nTapez sur Entrée pour continuer...");
//TODO Clear le buffer pour éviter les problèmes
if (getchar() == '\n') // getchar() pour récupérer le caractère entré par l'utilisateur
{
printf("\e[1;1H\e[2J"); // Clear le terminal
}
printf("\n=================================\n"); printf("\n=================================\n");
printf(" Menu Principal\n"); printf(" Menu Principal\n");
printf("=================================\n"); printf("=================================\n");
@ -21,7 +28,9 @@ int displayMenu(void)
printf("9. \u26A0 Débug\n"); printf("9. \u26A0 Débug\n");
printf("=================================\n"); printf("=================================\n");
printf("Votre choix : "); printf("Votre choix : ");
scanf("%d", &choice); scanf("%d%*c", &choice);
printf("\e[1;1H\e[2J");
return choice; return choice;
} }
@ -43,7 +52,7 @@ void global(void)
+var cagnotte: tableau des cagnottes des clients +var cagnotte: tableau des cagnottes des clients
*/ */
// Déclaration des variables // Déclaration des variables
int tLogArticle, tLogClient, choice; int tLogArticle, tLogClient, choice, status, currentUser;
int reference[tmaxArticles], clientID[tmaxClients], suspended[tmaxClients], isAdmin[tmaxClients]; int reference[tmaxArticles], clientID[tmaxClients], suspended[tmaxClients], isAdmin[tmaxClients];
float weight[tmaxArticles], volume[tmaxArticles], unitPrice[tmaxArticles], cagnotte[tmaxClients]; float weight[tmaxArticles], volume[tmaxArticles], unitPrice[tmaxArticles], cagnotte[tmaxClients];
// Chargement de toute les données // Chargement de toute les données
@ -53,17 +62,42 @@ void global(void)
while (choice != 4) while (choice != 4)
{ {
choice = displayMenu();
switch (choice) switch (choice)
{ {
case 1: case 1:
//TODO > Connexion status = login(clientID, isAdmin, tLogClient);
if(status == 1)
{
//TODO > Menu Admin
//adminMenu();
}
else if(status == 0)
{
//TODO > Menu Client
//clientMenu();
}
else
{
printf("Connexion échouée.\nRetour au menu principal...\n");
sleep(3);
}
break; break;
case 2: case 2:
//TODO > Inscription status = signup(clientID, cagnotte, suspended, isAdmin, &tLogClient);
if(status == 0)
{
printf("Inscription réussie.\nRetour au menu principal...\n");
sleep(3);
}
else
{
printf("Inscription échouée.\nRetour au menu principal...\n");
sleep(3);
}
break; break;
case 3: case 3:
//TODO > Faire opposition //TODO > Faire opposition
//opposition();
break; break;
case 4: case 4:
return; return;
@ -75,6 +109,7 @@ void global(void)
choice = displayMenu(); choice = displayMenu();
break; break;
} }
choice = displayMenu();
} }
} }

Loading…
Cancel
Save