From 5e22520d9095d773807281134e2d573c3ef1825d Mon Sep 17 00:00:00 2001 From: johnny Date: Wed, 11 Jan 2023 21:25:42 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20fonction=20de=20mise=20=C3=A0?= =?UTF-8?q?=20jour=20d'un=20choix=20et=20adaptadion=20de=20l'affichage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Commun.c | 314 +++++++++++++++++++++++++++++++++++++++++++++++++------ Commun.h | 12 ++- J2sae.c | 167 ++++++++++++++++++++++++----- J2sae.h | 4 +- 4 files changed, 435 insertions(+), 62 deletions(-) diff --git a/Commun.c b/Commun.c index 3fed3f0..8445bca 100644 --- a/Commun.c +++ b/Commun.c @@ -708,8 +708,8 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM int trouve; MaillonDept *m; system("clear"); - printf("____________________________________________________-\n"); - printf("| AFFICHAGE CANDIDAT |\n"); + printf("_____________________________________________________\n"); + printf("| MENU CANDIDAT |\n"); printf("|---------------------------------------------------|\n"); printf("| 1 Afficher les villes où il y a un IUT |\n"); printf("| 2 Afficher tous les départements dans chaque IUT |\n"); @@ -770,7 +770,7 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM afficheDeptDesIUT(tiut,*tLog); } printf("_____________________________________________________\n"); - printf("| AFFICHAGE CANDIDAT |\n"); + printf("| MENU CANDIDAT |\n"); printf("|---------------------------------------------------|\n"); printf("| 1 Afficher les villes où il y a un IUT |\n"); printf("| 2 Afficher tous les départements dans chaque IUT |\n"); @@ -786,7 +786,7 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM void clearpage(void) /* Permet de demander à l'utilisateur pour continuer à la suite d'une action et efface le contenu affiché à l'écran */ { char entre; - printf("\nappuyé sur la touche [ENTREE] pour continuer"); + printf("\nAppuyez sur la touche [ENTREE] pour continuer"); scanf("%c", &entre); system("clear"); } @@ -853,7 +853,9 @@ void enregistrement(VilleIUT *tiut[],int tLog) /* Permet l'enregistrement du tab // ########################################################################################### // ########################################################################################### -/************************************** Fonctiuons de Chargement ********************************************/ +#include "J2sae.h" + +/************************************** Fonctions de Chargement ********************************************/ /****************************************** Et de sauvegarde*************************************************/ /************************************************************************************************************/ @@ -897,6 +899,7 @@ Candidat * lireCandidat(FILE *flot) if(c == NULL) { printf("Erreur d'allocation mémoire candidat\n"); + fclose(flot); exit(1); } fscanf(flot, "%d%*c", &c->numeroC); @@ -907,6 +910,12 @@ Candidat * lireCandidat(FILE *flot) fscanf(flot, "%f%f%f%f%*c", &c->notes[0], &c->notes[1], &c->notes[2], &c->notes[3]); fscanf(flot, "%d%*c", &c->nombreChoix); c->tChoix = (Choix **)malloc(sizeof(Choix *) * c->nombreChoix); + if(c->tChoix == NULL) + { + printf("Erreur lors de l'allocation mémoire du tableau de choix\n"); + fclose(flot); + exit(1); + } while(i < c->nombreChoix) { c->tChoix[i] = lireChoix(flot); @@ -963,9 +972,9 @@ void sauvegarder(Candidat *tCand[], int tMax) void afficherChoix(Choix *c) { - printf("|_____________________________________________________________________________|\n"); - printf("| %-32s | %-32s | %1d | %1d |\n", c->ville, c->dep, c->decisionResp, c->decisionCand); - printf("|-----------------------------------------------------------------------------|\n"); + printf("|_______________________________________________________________________________|\n"); + printf("| %-32s | %-32s | %2d | %2d |\n", c->ville, c->dep, c->decisionResp, c->decisionCand); + printf("|-------------------------------------------------------------------------------|\n"); } void afficherCandidat(Candidat *c) @@ -980,8 +989,8 @@ void afficherCandChoix(Candidat *tCand[],int tMax) int i, j; for(i = 0; i < tMax; i++) { - printf("______________________________________________________________________________________________________________\n"); - printf("| Candidat |\n"); + printf("________________________________________________________________________________________________________________\n"); + printf("| Candidat |\n"); afficherCandidat(tCand[i]); printf("\n"); printf("_______________________________________________________________________________\n"); @@ -993,6 +1002,28 @@ void afficherCandChoix(Candidat *tCand[],int tMax) } } +void afficherCandDep(Candidat *tCand[], int tMax) +{ + int i, j; + char ville[31], dep[31]; + printf("Dans quelle ville se trouve le départment dont vous souhaitez afficher les candidats ?\nSaisie : "); + scanf("%s%*c", ville); + printf("\n"); + printf("Quelle est le nom du département dont vous souhaitez afficher les candidats ?\nSaisie : "); + scanf("%s%*c", dep); + printf("\n"); + for(i = 0; i < tMax; i++) + { + for(j = 0; j < tCand[i]->nombreChoix; j++) + { + if(strcmp(tCand[i]->tChoix[j]->ville, ville) == 0 && strcmp(tCand[i]->tChoix[j]->dep, dep) == 0) + { + afficherCandidat(tCand[i]); + } + } + } +} + /************************************ Fonctions de réallocation *********************************************/ /************************************************************************************************************/ @@ -1001,7 +1032,7 @@ void afficherCandChoix(Candidat *tCand[],int tMax) Candidat ** reallocationCand(Candidat *tCand[], int tMax) { Candidat **aux; - aux = (Candidat **)realloc(tCand, sizeof(Candidat *) * tMax + 1); + aux = (Candidat **)realloc(tCand, sizeof(Candidat *) * (tMax + 1)); if(aux == NULL) { printf("Erreur lors de la réallocation du tableau\n"); @@ -1012,12 +1043,12 @@ Candidat ** reallocationCand(Candidat *tCand[], int tMax) Choix ** reallocationChoix(Choix *tChoix[], int nbChoix) { Choix **aux; - aux = (Choix **)realloc(tChoix, sizeof(Choix *) * nbChoix + 1); + nbChoix = nbChoix + 1; + aux = (Choix **)realloc(tChoix, nbChoix * sizeof(Choix *)); if(aux == NULL) { printf("Erreur lors de la réallocation du tableau\n"); } - printf("Réallocation réussie :\n"); return aux; } @@ -1092,7 +1123,6 @@ int plusGrandChoix(Choix *tChoix[], int nombreChoix) void echangerChoix(Choix *tChoix[], int i, int j) { - printf("Echange Choix\n"); Choix *aux; aux = tChoix[i]; tChoix[i] = tChoix[j]; @@ -1104,7 +1134,7 @@ void echangerChoix(Choix *tChoix[], int i, int j) /************************************************************************************************************/ /************************************************************************************************************/ -int insererChoix(Choix *tChoix[], int nombreChoix) +Choix ** insererChoix(Choix *tChoix[], int *nombreChoix) { int pos, trouve, i; char ville[31], dep[31]; @@ -1115,33 +1145,176 @@ int insererChoix(Choix *tChoix[], int nombreChoix) printf("Quelle est le nom de la formation que vous souhaitez ajouter à vos choix ?\nSaisie : "); scanf("%s%*c", dep); printf("\n"); - pos = rechercherChoix(tChoix, nombreChoix, ville, dep, &trouve); + pos = rechercherChoix(tChoix, *nombreChoix, ville, dep, &trouve); if(trouve == 1) { printf("Erreur, ce choix figure déjà dans votre liste\n"); - return -1; + return tChoix; } c = (Choix *)malloc(sizeof(Choix)); if(c == NULL) { printf("Erreur d'allocation mémoire lors de l'insertion du choix\n"); - return -1; + return tChoix; } strcpy(c->ville, ville); strcpy(c->dep, dep); c->decisionResp = 0; c->decisionCand = 0; - tChoix = reallocationChoix(tChoix, nombreChoix); - for(i = nombreChoix; i > pos; i--) + tChoix = reallocationChoix(tChoix, *nombreChoix); + for(i = *nombreChoix; i > pos; i--) { tChoix[i] = tChoix[i - 1]; } tChoix[pos] = c; - afficherChoix(tChoix[pos]); - return nombreChoix + 1; + *nombreChoix = *nombreChoix + 1; + return tChoix; +} + +Choix ** supprimerChoix(Choix *tChoix[], int *nombreChoix) +{ + Choix **aux, *temp; + int i, pos, trouve; + char ville[31], dep[31], saisie; + printf("Dans quelle ville se trouve la formation que vous souhaitez retirer de vos choix ?\nSaisie : "); + scanf("%s%*c", ville); + printf("\n"); + printf("Quelle est le nom de la formation que vous souhaitez retirer de vos choix ?\nSaisie : "); + scanf("%s%*c", dep); + printf("\n"); + pos = rechercherChoix(tChoix, *nombreChoix, ville, dep, &trouve); + if(trouve == 0) + { + printf("Erreur, ce choix ne figure pas dans votre liste\n"); + return tChoix; + } + printf("Êtes-vous sur de vouloir supprimer ce choix ? (O/n)\nSaisie : "); + scanf("%c%*c", &saisie); + printf("\n"); + if(saisie == 'n' || saisie == 'N') + { + return tChoix; + } + temp = tChoix[pos]; + for(i = pos; i < *nombreChoix - 1; i++) + { + tChoix[i] = tChoix[i + 1]; + } + *nombreChoix = *nombreChoix - 1; + aux = (Choix **)realloc(tChoix, *nombreChoix * sizeof(Choix *)); + if(aux == NULL) + { + printf("Problème avec la réallocation lors de la suppression\n"); + return tChoix; + } + free(temp); + return aux; } +void miseAJourChoixCand(Choix *tChoix[], int nombreChoix) +{ + int pos, trouve, saisie; + char ville[31], dep[31]; + printf("Dans quelle ville se trouve la formation que vous souhaitez retirer de vos choix ?\nSaisie : "); + scanf("%s%*c", ville); + printf("\n"); + printf("Quelle est le nom de la formation que vous souhaitez retirer de vos choix ?\nSaisie : "); + scanf("%s%*c", dep); + printf("\n"); + pos = rechercherChoix(tChoix, nombreChoix, ville, dep, &trouve); + if(trouve == 0) + { + printf("Erreur, ce choix ne figure pas dans votre liste\n"); + return; + } + system("clear"); + if(tChoix[pos]->decisionCand == -1) + { + printf("Vous avez actuellement refusé la proposition d'admission de l'établissement\n\n"); + printf("|---------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|---------------------------------------|\n"); + printf("| 1 Accepter la proposition d'admission |\n"); + printf("| 2 Prendre un temps de réflexion |\n"); + printf("| 3 Ne rien changer |\n"); + printf("|---------------------------------------|\n"); + printf("Saisie : "); + scanf("%d%*c", &saisie); + printf("\n"); + if(saisie == 1) + { + tChoix[pos]->decisionCand = 1; + return; + } + if(saisie == 2) + { + tChoix[pos]->decisionCand = 0; + return; + } + if(saisie == 3) + { + return; + } + } + else if(tChoix[pos]->decisionCand == 0) + { + printf("Vous n'avez actuellement pris aucune décision\n\n"); + printf("|---------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|---------------------------------------|\n"); + printf("| 1 Refuser la proposition d'admission |\n"); + printf("| 2 Accepter la proposition d'admission |\n"); + printf("| 3 Ne rien changer |\n"); + printf("|---------------------------------------|\n"); + printf("Saisie : "); + scanf("%d%*c", &saisie); + printf("\n"); + if(saisie == 1) + { + tChoix[pos]->decisionCand = -1; + return; + } + if(saisie == 2) + { + tChoix[pos]->decisionCand = 1; + return; + } + if(saisie == 3) + { + return; + } + } + else if(tChoix[pos]->decisionCand == 1) + { + printf("Vous avez actuellement accepté la proposition d'admission de l'établissement\n\n"); + printf("|---------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|---------------------------------------|\n"); + printf("| 1 Refuser la proposition d'admission |\n"); + printf("| 2 Prendre un temps de réflexion |\n"); + printf("| 3 Ne rien changer |\n"); + printf("|---------------------------------------|\n"); + printf("Saisie : "); + scanf("%d%*c", &saisie); + printf("\n"); + if(saisie == 1) + { + tChoix[pos]->decisionCand = -1; + return; + } + if(saisie == 2) + { + tChoix[pos]->decisionCand = 0; + return; + } + if(saisie == 3) + { + return; + } + } +} + /*********************************** Fonctions de recherche *************************************************/ /************************************************************************************************************/ /************************************************************************************************************/ @@ -1179,34 +1352,111 @@ int rechercherChoix(Choix *tChoix[], int nombreChoix, char ville[], char dep[], } -int rechercherCandidat(Candidat *tCand[], int tMax, char nom[], char prenom[], int *trouve) +int rechercherCandidat(Candidat *tCand[], int tMax, int numeroC, int *trouve) { int inf = 0, sup = tMax - 1, m; while(inf <= sup) { m = (inf + sup) / 2; - if(strcmp(nom, tCand[m]->nom) == 0 && strcmp(prenom, tCand[m]->prenom) == 0) + if(numeroC == tCand[m]->numeroC) { *trouve = 1; return m; } - if(strcmp(nom, tCand[m]->nom) > 0) + if(numeroC > tCand[m]->numeroC) { inf = m + 1; } - if(strcmp(nom, tCand[m]->nom) < 0) + else { sup = m - 1; } - if(strcmp(nom, tCand[m]->nom) == 0 && strcmp(prenom, tCand[m]->prenom) > 0) + + } + *trouve = 0; + return inf; +} + + +/********************************** Fonction globale et menus ***********************************************/ +/************************************************************************************************************/ +/************************************************************************************************************/ + +void globale2(void) +{ + int tMax, pos, trouve, i; + Candidat **tCand, c; + tCand = chargementCandidats(&tMax); + sauvegarder(tCand, tMax); + triCandidats(tCand, tMax); + afficherCandChoix(tCand, tMax); + for(i = 0; i < tMax; i++) + { + triChoix(tCand[i]->tChoix, tCand[i]->nombreChoix); + } + menuCandidat2(tCand, tMax); +} + +void menuCandidat2(Candidat *tCand[], int tMax) +{ + int pos,trouve, saisie, i, numeroC; + system("clear"); + printf("Quel est votre numéro de candidat ?\nSaisie : "); + scanf("%d%*c", &numeroC); + printf("\n"); + pos = rechercherCandidat(tCand, tMax, numeroC, &trouve); + if(trouve == 0) + { + printf("Erreur, vous n'êtes pas inscrit dans la base de données\n"); + return; + } + system("clear"); + printf("|------------------------------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|------------------------------------------------------------|\n"); + printf("| 1 Afficher vos choix |\n"); + printf("| 2 Ajouter un choix |\n"); + printf("| 3 Supprimer un choix |\n"); + printf("| 4 Mettre à jour votre décision concernant un établissement |\n"); + printf("| 9 Quitter |\n"); + printf("|------------------------------------------------------------|\n"); + printf("Saisie : "); + scanf("%d%*c", &saisie); + printf("\n"); + while(saisie != 9) + { + system("clear"); + if(saisie == 1) { - inf = m + 1; + for(i = 0; i < tCand[pos]->nombreChoix; i++) + { + afficherChoix(tCand[pos]->tChoix[i]); + } } - if(strcmp(nom, tCand[m]->nom) == 0 && strcmp(prenom, tCand[m]->prenom) < 0) + if(saisie == 2) { - sup = m - 1; + tCand[pos]->tChoix = insererChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix); } + if(saisie == 3) + { + tCand[pos]->tChoix = supprimerChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix); + } + if(saisie == 4) + { + miseAJourChoixCand(tCand[pos]->tChoix, tCand[pos]->nombreChoix); + } + clearpage(); + printf("|------------------------------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|------------------------------------------------------------|\n"); + printf("| 1 Afficher vos choix |\n"); + printf("| 2 Ajouter un choix |\n"); + printf("| 3 Supprimer un choix |\n"); + printf("| 4 Mettre à jour votre décision concernant un établissement |\n"); + printf("| 9 Quitter |\n"); + printf("|------------------------------------------------------------|\n"); + printf("Saisie : "); + scanf("%d%*c", &saisie); + printf("\n"); } - *trouve = 0; - return inf; } \ No newline at end of file diff --git a/Commun.h b/Commun.h index cb7247a..92f4b98 100644 --- a/Commun.h +++ b/Commun.h @@ -89,7 +89,6 @@ void globale(void); // ########################################################################################### // ########################################################################################### - typedef struct { char ville[31]; @@ -122,6 +121,7 @@ void sauvegarder(Candidat *tCand[], int tMax); void afficherCandidat(Candidat *c); void afficherChoix(Choix *c); void afficherCandChoix(Candidat *tCand[],int tMax); +void afficherCandDep(Candidat *tCand[], int tMax); /* Fonctions de réallocation */ @@ -140,8 +140,14 @@ void echangerChoix(Choix *tChoix[], int i, int j); /* Fonctions de recherche */ int rechercherChoix(Choix *tChoix[], int nombreChoix, char ville[], char dep[], int *trouve); -int rechercherCandidat(Candidat *tCand[], int tMax, char nom[], char prenom[], int *trouve); +int rechercherCandidat(Candidat *tCand[], int tMax, int numeroC, int *trouve); /* Fonctions d'insertion/suppresion/maj*/ -int insererChoix(Choix *tChoix[], int nombreChoix); +Choix ** insererChoix(Choix *tChoix[], int *nombreChoix); +Choix ** supprimerChoix(Choix *tChoix[], int *nombreChoix); +void miseAJourChoixCand(Choix *tChoix[], int nombreChoix); + +/* Fonctions globale, menus*/ +void globale2(void); +void menuCandidat2(Candidat *tCand[], int tMax); \ No newline at end of file diff --git a/J2sae.c b/J2sae.c index 1bfbc18..e9942a0 100755 --- a/J2sae.c +++ b/J2sae.c @@ -1,6 +1,6 @@ #include "J2sae.h" -/************************************** Fonctiuons de Chargement ********************************************/ +/************************************** Fonctions de Chargement ********************************************/ /****************************************** Et de sauvegarde*************************************************/ /************************************************************************************************************/ @@ -117,9 +117,9 @@ void sauvegarder(Candidat *tCand[], int tMax) void afficherChoix(Choix *c) { - printf("|_____________________________________________________________________________|\n"); - printf("| %-32s | %-32s | %1d | %1d |\n", c->ville, c->dep, c->decisionResp, c->decisionCand); - printf("|-----------------------------------------------------------------------------|\n"); + printf("|_______________________________________________________________________________|\n"); + printf("| %-32s | %-32s | %2d | %2d |\n", c->ville, c->dep, c->decisionResp, c->decisionCand); + printf("|-------------------------------------------------------------------------------|\n"); } void afficherCandidat(Candidat *c) @@ -134,8 +134,8 @@ void afficherCandChoix(Candidat *tCand[],int tMax) int i, j; for(i = 0; i < tMax; i++) { - printf("______________________________________________________________________________________________________________\n"); - printf("| Candidat |\n"); + printf("________________________________________________________________________________________________________________\n"); + printf("| Candidat |\n"); afficherCandidat(tCand[i]); printf("\n"); printf("_______________________________________________________________________________\n"); @@ -194,7 +194,6 @@ Choix ** reallocationChoix(Choix *tChoix[], int nbChoix) { printf("Erreur lors de la réallocation du tableau\n"); } - printf("Réallocation réussie :\n"); return aux; } @@ -269,7 +268,6 @@ int plusGrandChoix(Choix *tChoix[], int nombreChoix) void echangerChoix(Choix *tChoix[], int i, int j) { - printf("Echange Choix\n"); Choix *aux; aux = tChoix[i]; tChoix[i] = tChoix[j]; @@ -314,7 +312,6 @@ Choix ** insererChoix(Choix *tChoix[], int *nombreChoix) tChoix[i] = tChoix[i - 1]; } tChoix[pos] = c; - afficherChoix(tChoix[pos]); *nombreChoix = *nombreChoix + 1; return tChoix; } @@ -360,6 +357,109 @@ Choix ** supprimerChoix(Choix *tChoix[], int *nombreChoix) } +void miseAJourChoixCand(Choix *tChoix[], int nombreChoix) +{ + int pos, trouve, saisie; + char ville[31], dep[31]; + printf("Dans quelle ville se trouve la formation que vous souhaitez retirer de vos choix ?\nSaisie : "); + scanf("%s%*c", ville); + printf("\n"); + printf("Quelle est le nom de la formation que vous souhaitez retirer de vos choix ?\nSaisie : "); + scanf("%s%*c", dep); + printf("\n"); + pos = rechercherChoix(tChoix, nombreChoix, ville, dep, &trouve); + if(trouve == 0) + { + printf("Erreur, ce choix ne figure pas dans votre liste\n"); + return; + } + system("clear"); + if(tChoix[pos]->decisionCand == -1) + { + printf("Vous avez actuellement refusé la proposition d'admission de l'établissement\n\n"); + printf("|---------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|---------------------------------------|\n"); + printf("| 1 Accepter la proposition d'admission |\n"); + printf("| 2 Prendre un temps de réflexion |\n"); + printf("| 3 Ne rien changer |\n"); + printf("|---------------------------------------|\n"); + printf("Saisie : "); + scanf("%d%*c", &saisie); + printf("\n"); + if(saisie == 1) + { + tChoix[pos]->decisionCand = 1; + return; + } + if(saisie == 2) + { + tChoix[pos]->decisionCand = 0; + return; + } + if(saisie == 3) + { + return; + } + } + else if(tChoix[pos]->decisionCand == 0) + { + printf("Vous n'avez actuellement pris aucune décision\n\n"); + printf("|---------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|---------------------------------------|\n"); + printf("| 1 Refuser la proposition d'admission |\n"); + printf("| 2 Accepter la proposition d'admission |\n"); + printf("| 3 Ne rien changer |\n"); + printf("|---------------------------------------|\n"); + printf("Saisie : "); + scanf("%d%*c", &saisie); + printf("\n"); + if(saisie == 1) + { + tChoix[pos]->decisionCand = -1; + return; + } + if(saisie == 2) + { + tChoix[pos]->decisionCand = 1; + return; + } + if(saisie == 3) + { + return; + } + } + else if(tChoix[pos]->decisionCand == 1) + { + printf("Vous avez actuellement accepté la proposition d'admission de l'établissement\n\n"); + printf("|---------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|---------------------------------------|\n"); + printf("| 1 Refuser la proposition d'admission |\n"); + printf("| 2 Prendre un temps de réflexion |\n"); + printf("| 3 Ne rien changer |\n"); + printf("|---------------------------------------|\n"); + printf("Saisie : "); + scanf("%d%*c", &saisie); + printf("\n"); + if(saisie == 1) + { + tChoix[pos]->decisionCand = -1; + return; + } + if(saisie == 2) + { + tChoix[pos]->decisionCand = 0; + return; + } + if(saisie == 3) + { + return; + } + } +} + /*********************************** Fonctions de recherche *************************************************/ /************************************************************************************************************/ /************************************************************************************************************/ @@ -439,9 +539,6 @@ void globale(void) { triChoix(tCand[i]->tChoix, tCand[i]->nombreChoix); } - afficherCandChoix(tCand, tMax); - pos = rechercherChoix(tCand[0]->tChoix, 4, "Aurillac", "Biologie", &trouve); - printf("Choix trouve : %d\nSa position : %d\nNom Ville : %s\tNom dep : %s\n", trouve, pos, tCand[0]->tChoix[pos]->ville, tCand[0]->tChoix[pos]->dep); menuCandidat(tCand, tMax); } @@ -453,18 +550,22 @@ void menuCandidat(Candidat *tCand[], int tMax) scanf("%d%*c", &numeroC); printf("\n"); pos = rechercherCandidat(tCand, tMax, numeroC, &trouve); - printf("Candidat trouve : %d\nSa position : %d\nNom : %s\tPrenom : %s\n", trouve, pos, tCand[pos]->nom, tCand[pos]->prenom); if(trouve == 0) { printf("Erreur, vous n'êtes pas inscrit dans la base de données\n"); return; } - printf("Que souhaitez-vous faire ?\n"); - printf("1 Afficher vos choix\n"); - printf("2 Ajouter un choix\n"); - printf("3 Supprimer un choix\n"); - printf("4 Afficher les candidats dans un département\n"); - printf("9 Quitter\nSaisie : "); + system("clear"); + printf("|------------------------------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|------------------------------------------------------------|\n"); + printf("| 1 Afficher vos choix |\n"); + printf("| 2 Ajouter un choix |\n"); + printf("| 3 Supprimer un choix |\n"); + printf("| 4 Mettre à jour votre décision concernant un établissement |\n"); + printf("| 9 Quitter |\n"); + printf("|------------------------------------------------------------|\n"); + printf("Saisie : "); scanf("%d%*c", &saisie); printf("\n"); while(saisie != 9) @@ -474,7 +575,6 @@ void menuCandidat(Candidat *tCand[], int tMax) { for(i = 0; i < tCand[pos]->nombreChoix; i++) { - printf("Affichage des choix\nNombre de choix : %d\n", tCand[pos]->nombreChoix); afficherChoix(tCand[pos]->tChoix[i]); } } @@ -488,14 +588,29 @@ void menuCandidat(Candidat *tCand[], int tMax) } if(saisie == 4) { - afficherCandDep(tCand, tMax); + miseAJourChoixCand(tCand[pos]->tChoix, tCand[pos]->nombreChoix); } - printf("Que souhaitez-vous faire ?\n"); - printf("1 Afficher vos choix\n"); - printf("2 Ajouter un choix\n"); - printf("3 Supprimer un choix\n"); - printf("9 Quitter\nSaisie : "); + clearpage(); + printf("|------------------------------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|------------------------------------------------------------|\n"); + printf("| 1 Afficher vos choix |\n"); + printf("| 2 Ajouter un choix |\n"); + printf("| 3 Supprimer un choix |\n"); + printf("| 4 Mettre à jour votre décision concernant un établissement |\n"); + printf("| 9 Quitter |\n"); + printf("|------------------------------------------------------------|\n"); + printf("Saisie : "); scanf("%d%*c", &saisie); printf("\n"); } +} + +void clearpage(void) /* Permet de demander à l'utilisateur pour continuer à la suite d'une action et efface le contenu affiché à l'écran */ +{ + char entre; + printf("\n"); + printf("Appuyez sur la touche [ENTREE] pour continuer"); + scanf("%c", &entre); + system("clear"); } \ No newline at end of file diff --git a/J2sae.h b/J2sae.h index 5da707a..516de79 100755 --- a/J2sae.h +++ b/J2sae.h @@ -80,7 +80,9 @@ int rechercherCandidat(Candidat *tCand[], int tMax, int numeroC, int *trouve); Choix ** insererChoix(Choix *tChoix[], int *nombreChoix); Choix ** supprimerChoix(Choix *tChoix[], int *nombreChoix); +void miseAJourChoixCand(Choix *tChoix[], int nombreChoix); /* Fonctions globale, menus*/ void globale(void); -void menuCandidat(Candidat *tCand[], int tMax); \ No newline at end of file +void menuCandidat(Candidat *tCand[], int tMax); +void clearpage(void); \ No newline at end of file