Menu utilisateurs + fonctions ajout, modifNbPlaces et ModifResp + structures

master
Corentin LEMAIRE 2 years ago
parent 1768801e7a
commit bfea3c1764

@ -33,15 +33,13 @@ void menuPrincipal(void){
printf("(9) Quitter\n");
printf("\nVotre choix : ");
scanf("%d", &choix);
choix = fonctionChoix();
switch (choix){
case 1:
printf("sousMenuUtilisateur();\n"); // Sous Menu Utilisateur
sousMenuUtilisateur();
break;
@ -102,7 +100,7 @@ void sousMenuAdministrateur(void){
printf("\033[1;31m"); // Rouge
printf("Mot de passe incorrecte. ");
printf("Mot de passe incorrect. ");
printf("\033[0m"); // Reset couleur
@ -140,9 +138,7 @@ void sousMenuAdministrateur(void){
printf("(9) Retour\n");
printf("\nVotre choix : ");
scanf("%d", &choix);
choix = fonctionChoix();
switch (choix){
@ -201,6 +197,207 @@ void sousMenuAdministrateur(void){
}
}
int fonctionChoix(void){
int choix;
printf("\nVotre choix : ");
scanf("%d", &choix);
return choix;
}
void affichageSousMenuUtilisateur(void){
printf("-------------------------------\n");
printf("\033[1;37m"); // Gras
printf("\tMENU UTILISATEUR\t\n");
printf("\033[0m"); // Reset couleur
printf("-------------------------------\n\n");
printf("(1) Voir les villes où il y a un IUT\n");
printf("(2) Voir les département d'un IUT\n");
printf("(3) Voir le nombre de places en première année d'un département d'un IUT\n");
printf("(4) Voir les IUT possédant un département en particulier\n");
printf("(9) Retour\n");
}
void switchUtilisateur(int choix){
switch (choix){
case 1:
printf("Villes avec IUT\n"); //
break;
case 2:
printf("Départements d'un IUT\n"); //
break;
case 3:
printf("Nombre de places d'un IUT\n"); //
break;
case 4:
printf("IUT avec département en particulier\n"); //
break;
case 9:
printf("\e[1;1H\e[2J"); // Clear terminal
return;
default:
printf("\e[1;1H\e[2J"); // Clear terminal
printf("-------------------------------\n");
printf("\033[1;31m"); // Rouge
printf("Erreur : Saisie incorrecte.\n\a"); // \a -> Cloche
printf("\033[0m"); // Reset couleur
printf("-------------------------------\n");
}
}
void sousMenuUtilisateur(void){
int choix;
while (choix != 9){
affichageSousMenuUtilisateur();
choix = fonctionChoix();
switchUtilisateur(choix);
}
}
ListeDept Listenouv(void){
ListeDept l;
l = NULL;
return l;
}
ListeDept inserer(ListeDept l, char* departement, int nbP, char* nomResp){
if (l == NULL)
return insererEnTete(l, departement, nbP, nomResp);
if (strcmp(departement, l -> departement) < 0)
return insererEnTete(l, departement, nbP, nomResp);
if (strcmp(departement, l -> departement) == 0)
return l;
l -> suiv = inserer(l->suiv, departement, nbP, nomResp);
return l;
}
ListeDept insererEnTete(ListeDept l, char* departement, int nbP, char* nomResp){
MaillonDept *m;
m = (MaillonDept *)malloc(sizeof(MaillonDept));
if (m == NULL)
{
printf("Problème malloc\n");
exit(1);
}
*m -> departement = departement;
m -> nbP = nbP;
*m -> nomResp = nomResp;
m -> suiv = l;
return m;
}
MaillonDept modifNbPlaces(MaillonDept m){
int nvNbPlaces;
printf("Combien de places à présent ? ");
scanf("%d", &nvNbPlaces);
while (nvNbPlaces < 1){
printf("Nombre incorrect, réessayez !\n");
printf("Combien de places à présent ? ");
scanf("%d", &nvNbPlaces);
}
m.nbP = nvNbPlaces;
return m;
}
MaillonDept modifResp(MaillonDept m){
char nomResp[22];
printf("Nouveau nom de chef de département ? ");
fgets(nomResp, 22, stdin);
nomResp[strlen(nomResp) - 1 ] = '\0';
*m.nomResp = nomResp;
return m;
}
/* EN COURS
void rechercherVille(int* tiut, int tlog, int val, int *coderet, int *pos){
int i;

@ -6,19 +6,17 @@
*@brief : Résumé : Fichier .h regroupant les fonctions utilisées dans SAE2.c
*/
typedef struct{
typedef struct maillon{
char ville[30];
int suiv; // Modifier par type MaillonDept*
char departement[32];
}ldept;
int nbP;
typedef struct{
int maillon; // Modifier par type MaillonDept
}ListeDept;
char nomResp[22];
struct maillon *suiv;
}MaillonDept, *ListeDept;
typedef struct{
@ -29,7 +27,14 @@ typedef struct{
}VilleIUT;
void menuPrincipal(void);
void sousMenuAdministrateur(void);
void sousMenuAdministrateur(void);
int fonctionChoix(void);
void affichageSousMenuUtilisateur(void);
void switchUtilisateur(int choix);
void sousMenuUtilisateur(void);

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save