-Menu candidat fonctionnel, -saisieCandidature -existedept -Changements de supprimer et ajouter candidatures : Enleve et rajoute 1 respectivement DANS la fonction pour nbchoix du candidats -Plus de clean et appuyer pour continuer pour afficherVillesIut

master
loris OBRY 2 years ago
parent 370c32992c
commit 59088274e0

@ -10,7 +10,7 @@
*/
#ifdef _WIN32
#define clean system("cls");
#define clean system("clear");
#define color system("color 70");
void testColor(void);
#endif
@ -111,7 +111,9 @@ int existeUtilisateur(char * utilisateur, int * indice, Log * tLog, int nbLog);
int mdpValide(char * mdp, int indice, Log * tLog);
//void menuVisiteur(VilleIut *villeIut, int nbVilles);
void menuVisiteur(Log * tLog, int nbLog, VilleIut *tIut[], int nbVilles);
void menuCandidat(Log * tLog, int nbLog, VilleIut *tIut[], int nbVilles);
void menuCandidat(Log * tLog, int nbLog, VilleIut *tIut[], int nbVilles, Candidat *c);
void saisirCandidature(char ville[], char dep[], VilleIut *tiut[], int nbVille);
VilleIut *saisieIut(VilleIut *tiut[], int nbVille, int *res);
int choixMenuCandidat(void);
int afficherMenuCandidat(void);
int afficherMenuVisiteur(void);
@ -134,9 +136,9 @@ void menuAdmin(VilleIut *tiut[], int nbVilles);
void afficherUnCandidat(Candidat candidat);
void afficherCandidats(Candidat **candidats, int nbCandidats);
int creerCandidat(Candidat *tCand[], int nbCandidats);
lChoix supprimerCandidature( lChoix l, int nbchoix);
lChoix supprimerCandidature( lChoix l, int *nbchoix);
lChoix supprmRecru( lChoix l, int rep );
lChoix creerCandidature(lChoix choixCandid, char ville[50], char departement[50], int decision, int validation);
lChoix creerCandidature(lChoix choixCandid, char ville[50], char departement[50], int decision, int validation, int *nbchoix);
ListeDeptV2 configurationDeptV2( ListeDept ldept );
@ -149,6 +151,7 @@ ListeDept ajouterDept(ListeDept ldept, char nomDept[], char resp[], int nbP);
ListeDept listenouv();
bool vide(ListeDept ldept);
int longueur(ListeDept ldept);
int existeDept(ListeDept ldept, char nom[]);
void afficherListe(ListeDept ldept);
// Choix.c

@ -135,6 +135,17 @@ int longueur(ListeDept ldept)
return i;
}
int existeDept(ListeDept ldept, char nom[])
{
while (ldept)
{
if (strcmp(ldept->nomDept, nom) == 0)
return 1;
ldept = ldept->suiv;
}
return 0;
}
/**
* @brief Affiche tous les départements d'une liste, avec leurs noms, leurs responsables et leur nombre de places, sous forme de tableau.
* @param ldept Liste de départements à afficher.

@ -8,9 +8,8 @@ int main(void)
// #ifdef _WIN32
// color
// #endif
guillaume();
//testCharge();
//Globale();
Globale();
//testJean();
return 0;

@ -17,8 +17,9 @@ void Globale(void)
//printf(" \n ---> lancement de la fonction globale.... \n\n");
Log * tLog;
VilleIut ** tIut;
Candidat *tCand[50];
int nbVilles;
int nbCand = 0;
int nbLog;
int nbIut, nbIutMax;
@ -29,10 +30,11 @@ void Globale(void)
//nbVilles = chargIutDon(tIut, 50, "../donnees/iut.don");
//Appel du menu visiteur
menuVisiteur(tLog, nbLog, tIut, nbIut);
//Sauvegarde dans les fichiers
//menuVisiteur(tLog, nbLog, tIut, nbIut);
//TEST menu candidat en attendant la conexion et tout la
nbCand = creerCandidat(tCand, nbCand);
menuCandidat(tLog, nbLog, tIut, nbIut, tCand[0]); //Sauvegarde dans les fichiers
}
/**
@ -145,11 +147,12 @@ void menuVisiteur(Log * tLog, int nbLog, VilleIut *tIut[], int nbIut)
* choixMenuCandidat. Selon le choix de l'utilisateur, la fonction appelle la fonction correspondante
* ou met fin à l'exécution de la fonction.
*/
void menuCandidat(Log * tLog, int nbLog, VilleIut *tIut[], int nbVilles)
void menuCandidat(Log * tLog, int nbLog, VilleIut *tIut[], int nbVilles, Candidat *c)
{
int choix;
int actif = 1;
int decision = 0, validation = 0;
char ville[30], dep[30];
clean
while(actif)
@ -159,13 +162,22 @@ void menuCandidat(Log * tLog, int nbLog, VilleIut *tIut[], int nbVilles)
switch(choix)
{
case 1:
//affiche les candidatures
afficherUnCandidat(*c);
getchar();
clean
break;
case 2:
//Creer une candidature
afficheVillesIUT(tIut, nbVilles - 1);
saisirCandidature(ville, dep, tIut, nbVilles);
c->lchoix = creerCandidature(c->lchoix, ville, dep, decision, validation, &c->nbChoix);
c->nbChoix += 1;
printf("%s\n", c->lchoix->ville);
printf("Operation validee\n");
getchar();
clean
break;
case 3 :
//Modifier une candidature
c->lchoix = supprimerCandidature(c->lchoix, &c->nbChoix);
break;
case 4 :
//Supprimer une candidature
@ -177,6 +189,42 @@ void menuCandidat(Log * tLog, int nbLog, VilleIut *tIut[], int nbVilles)
}
}
/**
@brief Cette fonction permet à l'utilisateur de saisir les informations sur une candidature. Il doit d'abord saisir le nom de la ville,
puis le nom du département correspondant. Si les informations saisies ne sont pas valides, l'utilisateur est invité à les resaisir.
@param ville Nom de la ville saisie
@param dep Nom du département saisi
@param tiut Liste des villes et départements
@param nbVille Nombre de villes dans la liste
@return void
*/
void saisirCandidature(char ville[], char dep[], VilleIut *tiut[], int nbVille)
{
int pos, res;
printf("Veuillez saisir le nom de la ville\n");
scanf("%s", ville);
pos = existeVille(tiut, ville, nbVille);
while ( pos == -1)
{
printf("Veuillez saisir le nom de la ville\n");
scanf("%s", ville);
pos = existeVille(tiut, ville, nbVille);
}
afficherListe(tiut[pos]->lDept);
printf("Veuilllez saisir le nom de departement\n");
scanf("%s", dep);
res = existeDept(tiut[pos]->lDept, dep);
while (res == 0)
{
afficherListe(tiut[pos]->lDept);
printf("Veuilllez saisir le nom de departement\n");
scanf("%s", dep);
res = existeDept(tiut[pos]->lDept, dep);
}
}
/**
@brief affiche le menu des candidats et renvoie le choix de l'utilisateur
@ -208,8 +256,8 @@ int afficherMenuCandidat(void)
int choix;
printf("============================================================\n\t\t\tMENU CANDIDAT\n============================================================\n\n");
printf("\t1. Creer une candidature\n");
printf("\t2. Modifier une candidature\n");
printf("\t1. Afficher son profil\n");
printf("\t2. Ajouter une candidature\n");
printf("\t3. Supprimer une candidature\n");
printf("\t0. Quitter\n");
printf("\nChoix : ");
@ -583,11 +631,6 @@ void afficheVillesIUT(VilleIut *tiut[], int nbVilles)
// Affichage du nom de la ville
printf(" -> %s\n", tiut[i]-> nom);
}
printf("\nAppuyez sur entree pour continuer...\n");
scanf("%*c");
clean
}
/**
@ -799,7 +842,7 @@ int creerCandidat(Candidat *tCand[], int nbCandidats)
*
* @return la liste avec le choix en moins
*/
lChoix supprimerCandidature( lChoix l, int nbchoix )
lChoix supprimerCandidature( lChoix l, int *nbchoix)
{
lChoix temp = l;
@ -813,7 +856,7 @@ lChoix supprimerCandidature( lChoix l, int nbchoix )
printf( " -----------------------------\n\n");
int rep = 0, c = 0;
for( int i = 0; i < nbchoix; i ++ )
for( int i = 0; i < *nbchoix; i ++ )
{
printf(" %d.) Ville : %10s ; Departement : %10s \n",i + 1, l -> ville, l -> departement);
l = l -> suiv;
@ -822,7 +865,7 @@ lChoix supprimerCandidature( lChoix l, int nbchoix )
printf(" \n\n --> Quel choix supprimer ? : ");
scanf("%d%*c", &rep);
temp = supprmRecru( temp, rep );
*nbchoix -= 1;
return temp;
}
@ -849,7 +892,7 @@ lChoix supprmRecru( lChoix l, int rep )
* @param validation 0 par defaut
* @return Liste mis à jour
*/
lChoix creerCandidature(lChoix choixCandid, char ville[], char departement[], int decision, int validation)
lChoix creerCandidature(lChoix choixCandid, char ville[], char departement[], int decision, int validation, int *nbchoix)
{
if(choixCandid == NULL)
return ajouterEnTeteC(choixCandid, ville, departement, decision, validation);
@ -857,7 +900,8 @@ lChoix creerCandidature(lChoix choixCandid, char ville[], char departement[], in
return ajouterEnTeteC(choixCandid, ville, departement, decision, validation);
if(strcmp(ville, choixCandid->ville) == 0 && strcmp(departement, choixCandid->departement) < 0)
return ajouterEnTeteC(choixCandid, ville, departement, decision, validation);
choixCandid->suiv = creerCandidature(choixCandid->suiv, ville, departement, 0, 0);
choixCandid->suiv = creerCandidature(choixCandid->suiv, ville, departement, 0, 0, nbchoix);
*nbchoix += 1;
return choixCandid;
}

@ -37,7 +37,7 @@
// }
/*
void guillaume(void)
{
Candidat *tCandid[50];
@ -76,7 +76,6 @@ void guillaume(void)
afficherUnCandidat(*tCandid[0]);
}
*/

Loading…
Cancel
Save