diff --git a/Commun.c b/Commun.c index b2dfca2..133b57c 100644 --- a/Commun.c +++ b/Commun.c @@ -25,9 +25,9 @@ ListeDept insérerDept(ListeDept lDept, Departement d) { if(lDept == NULL) return insérerEntete(lDept,d); - if(d.dept < lDept->d.dept) + if(strcmp(d.dept, lDept->d.dept) < 0) return insérerEntete(lDept,d); - if(d.dept == lDept->d.dept) + if(strcmp(d.dept,lDept->d.dept) == 0) printf("Département déjà présent dans cet IUT\n"); return lDept; lDept->suiv = insérerDept(lDept->suiv,d); @@ -52,9 +52,9 @@ ListeDept supprimerDept(ListeDept lDept, Departement d) { if(lDept == NULL) return lDept; - if(d.dept < lDept->d.dept) + if(strcmp(d.dept, lDept->d.dept) < 0) return lDept; - if(d.dept == lDept->d.dept) + if(strcmp(d.dept,lDept->d.dept) == 0) return supprimerEntete(lDept); lDept->suiv = supprimerDept(lDept->suiv,d); return lDept; @@ -91,11 +91,101 @@ bool rechercherDept(ListeDept lDept, Departement d) { if(vide(lDept)) return false; - if(d.dept < lDept->d.dept) + if(strcmp(d.dept, lDept->d.dept) < 0) return false; - if(d.dept == lDept->d.dept) + if(strcmp(d.dept,lDept->d.dept) == 0) return true; return rechercherDept(lDept->suiv, d); } +int login(void) +{ + int i = 3; + char id, mdp[31] = "mettez20svp", mdpatrouve[31]; + system("clear"); + printf("################################################################\n\tBienvenue!\n\n\n\tSouhaitez-vous vous connecter en tant qu'utilisateur ou administeur? (U/A)\t"); + scanf("%c%*c",&id); + if(id == 'q') + return -1; + while(id != 'A' && id != 'a' && id != 'U' && id != 'u') + { + system("clear"); + printf("################################################################\n\tMauvaise saisie (q pour quitter)\n\n\n\tSouhaitez-vous vous connecter en tant qu'utilisateur ou administeur? (U/A)\t"); + scanf("%c%*c",&id); + if(id == 'q') + return -1; + } + if(id == 'A' || id == 'a') + { + while(i != 0) + { + printf("\n\n\n\tMot de passe :\t"); + system("stty -echo"); + fgets(mdpatrouve, 31, stdin); + mdpatrouve[strlen(mdpatrouve) - 1] = '\0'; + if(strcmp(mdpatrouve, mdp) == 0 ) + { + system("stty echo"); + return 1; + } + else + { + i--; + printf("Mot de passe incorrect, il vous reste %d chances\n",i); + } + system("stty echo"); + } + return -1; + } + else return 0; + system("clear"); +} + + +void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax) +{ + int select = 0; + while(select != 9) + { + system("clear"); + printf("\t AFFICHAGE ADMIN\n\n"); + printf("1\tModifier le nombre de places dans un département\n"); + printf("2\tCréer un nouveau département\n"); + printf("3\tSupprimer un département\n"); + printf("4\tLancer/Arrêter la phase de candidature\n"); + printf("5\tModifer le nom du responsable d'un département\n"); + scanf("%d",&select); + } +} + +void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax) +{ + int select = 0; + while(select != 9) + { + system("clear"); + printf("\t AFFICHAGE CANDIDAT \n\n"); + printf("1\tRechercher les villes où il y a un IUT\n"); + printf("2\tRechercher chaque département dans les IUT\n"); + printf("3\tNombres de places en 1A\n"); + printf("4\tRechercher un département dans les IUT\n"); + scanf("%d",&select); + } +} + + + +void clearpage(void) +{ + char entre; + printf("\nappuyé sur la touche [ENTREE] pour continuer"); + scanf("%*c%c", &entre); + system("clear"); +} + + +void afficherPlace(Departement m) +{ + printf("\nPour ce département il y a %d places en 1ère année \n\n",m.nbP); +} \ No newline at end of file diff --git a/Jsae.c b/Jsae.c index 8e9443e..faccdf5 100644 --- a/Jsae.c +++ b/Jsae.c @@ -72,12 +72,14 @@ int insérerVille(VilleIUT *tiut[], char nomV[], Departement d, int *tLog, int t void afficherDep(Departement d) { - printf("%s\t%d\t%s\n", d.dept, d.nbP, d.respAd); + printf("| %-32s\t%3d\t%-32s |\n", d.dept, d.nbP, d.respAd); } void afficherVille(VilleIUT v) { - printf("%s\t", v.nom); + printf("|----------------------------------|\n"); + printf("| %-32s |\n", v.nom); + printf("|----------------------------------|\n"); } void afficherTIUT(VilleIUT *tiut[], int tLog) @@ -137,7 +139,7 @@ int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], int *trouve) void globale(void) { - int tLog; + int tLog, retour; VilleIUT *tiut[100]; if(tiut == NULL) { @@ -145,12 +147,22 @@ void globale(void) exit(1); } tLog = chargement(tiut,100); - printf("Tlog : %d\n", tLog); if(tLog < 0) { printf("Le programme ne peut pas fonctionner\n"); exit(1); } - afficherVilleDep(tiut, tLog); - afficherDep(tiut[0]->lDept->d); + retour = login(); + while(retour != -1) + { + if(retour == 1) + { + menuAdmin(tiut, &tLog, 100); + } + if(retour == 0) + { + menuCandidat(tiut, &tLog, 100); + } + retour = login(); + } } \ No newline at end of file diff --git a/Jsae.h b/Jsae.h index 33b5a19..0c04747 100644 --- a/Jsae.h +++ b/Jsae.h @@ -34,6 +34,11 @@ ListeDept supprimerDept(ListeDept lDept, Departement d); int longueur(ListeDept lDept); bool vide(ListeDept lDept); bool rechercherDept(ListeDept lDept, Departement d); +int login(void); +void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax); +void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax); +void clearpage(void); +void afficherPlace(Departement m); void afficherDep(Departement d); void afficherVille(VilleIUT v); void afficherTIUT(VilleIUT *tiut[], int tLog);