You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
191 lines
3.9 KiB
191 lines
3.9 KiB
#include "Jsae.h"
|
|
|
|
ListeDept listeDeptNouv(void)
|
|
{
|
|
ListeDept lDept;
|
|
lDept = NULL;
|
|
return lDept;
|
|
}
|
|
|
|
ListeDept insérerEntete(ListeDept lDept,Departement d)
|
|
{
|
|
MaillonDept *m;
|
|
m = (MaillonDept *)malloc(sizeof(MaillonDept));
|
|
if(m == NULL)
|
|
{
|
|
printf("Problème d'allocation mémoire lors de l'insertion\n");
|
|
exit(1);
|
|
}
|
|
m->d = d;
|
|
m->suiv = lDept;
|
|
return m;
|
|
}
|
|
|
|
ListeDept insérerDept(ListeDept lDept, Departement d)
|
|
{
|
|
if(lDept == NULL)
|
|
return insérerEntete(lDept,d);
|
|
if(strcmp(d.dept, lDept->d.dept) < 0)
|
|
return insérerEntete(lDept,d);
|
|
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);
|
|
return lDept;
|
|
}
|
|
|
|
ListeDept supprimerEntete(ListeDept lDept)
|
|
{
|
|
ListeDept aux;
|
|
if(lDept == NULL)
|
|
{
|
|
printf("Opération interdite\n");
|
|
exit(1);
|
|
}
|
|
aux = lDept;
|
|
lDept = lDept->suiv;
|
|
free(aux);
|
|
return lDept;
|
|
}
|
|
|
|
ListeDept supprimerDept(ListeDept lDept, Departement d)
|
|
{
|
|
if(lDept == NULL)
|
|
return lDept;
|
|
if(strcmp(d.dept, lDept->d.dept) < 0)
|
|
return lDept;
|
|
if(strcmp(d.dept,lDept->d.dept) == 0)
|
|
return supprimerEntete(lDept);
|
|
lDept->suiv = supprimerDept(lDept->suiv,d);
|
|
return lDept;
|
|
}
|
|
|
|
int longueur(ListeDept lDept)
|
|
{
|
|
int compt = 0;
|
|
while(lDept != NULL)
|
|
{
|
|
compt = compt + 1;
|
|
lDept = lDept->suiv;
|
|
}
|
|
return compt;
|
|
}
|
|
|
|
bool vide(ListeDept lDept)
|
|
{
|
|
if(lDept == NULL)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
|
|
/*int tete(Liste l){
|
|
if(l==NULL){
|
|
printf("Opération interdite\n");
|
|
exit(1)
|
|
}
|
|
return l->v;
|
|
}*/
|
|
|
|
bool rechercherDept(ListeDept lDept, Departement d)
|
|
{
|
|
if(vide(lDept))
|
|
return false;
|
|
if(strcmp(d.dept, lDept->d.dept) < 0)
|
|
return false;
|
|
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);
|
|
} |