From 13a9d34ad06d171e25c42f2e08e0461225ea847c Mon Sep 17 00:00:00 2001 From: johnny Date: Thu, 12 Jan 2023 13:57:47 +0100 Subject: [PATCH] Ajout des structures de la fonction suppression candidat et maj de misaAJourCand --- Commun.c | 89 +++++++++++++++----------------------------------------- Commun.h | 8 +++-- J2sae.c | 80 ++++++++++---------------------------------------- J2sae.h | 6 ++-- 4 files changed, 48 insertions(+), 135 deletions(-) diff --git a/Commun.c b/Commun.c index d686569..1d2bb6a 100644 --- a/Commun.c +++ b/Commun.c @@ -904,6 +904,7 @@ Candidat * lireCandidat(FILE *flot) /* Fonction permettant de lire un candidat d fgets(c->prenom, 31, flot); c->prenom[strlen(c->prenom) - 1] = '\0'; fscanf(flot, "%f%f%f%f%*c", &c->notes[0], &c->notes[1], &c->notes[2], &c->notes[3]); + c->moyenne = (c->notes[0] + c->notes[1] + c->notes[2] + c->notes[3]) / 4; fscanf(flot, "%d%*c", &c->nombreChoix); c->tChoix = (Choix **)malloc(sizeof(Choix *) * c->nombreChoix); /* Allocation dynamique du tableau de pointeurs vers des structures Choix*/ if(c->tChoix == NULL) /* pour le chargement des choix du candidats */ @@ -1225,83 +1226,27 @@ void miseAJourChoixCand(Choix *tChoix[], int nombreChoix) /* Fontcion permettant return; } system("clear"); - if(tChoix[pos]->decisionCand == -1) /* Affichage d'un menu adapté pour chaque cas ; le candidat peut choisir entre deux option ou bien ne rien faire */ - { - 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) + 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("| 1 Accepter la proposition d'admission |\n"); + printf("| 2 Refuser 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; + tChoix[pos]->decisionCand = -1; return; } if(saisie == 3) @@ -1552,6 +1497,11 @@ FileCand supt(FileCand f) return f; } +FileCand supCand(FileCand f, int numeroC) +{ + +} + Candidat * tete(FileCand f) { if(vide(f)) @@ -1616,17 +1566,17 @@ void afficher(FileCand f) void globale(void) /* Permet de gérer l'exécution du programme */ { - int tMax, pos, trouve, i; - Candidat **tCand, c; /* Initialisation du tableau de candidats */ + int tMax, pos, trouve, i, j; + Candidat **tCand, c **aux; /* Initialisation du tableau de candidats */ tCand = chargementCandidats(&tMax); /* Remplissage du tableau par chargement */ triCandidats(tCand, tMax); /* Tri du tableau */ for(i = 0; i < tMax; i++) /* Tri du tableau choix pour chaque candidat */ { triChoix(tCand[i]->tChoix, tCand[i]->nombreChoix); } - pos = rechercherChoix(tCand[3]->tChoix, tCand[3]->nombreChoix, "Clermont-Ferrand", "Informatique", &trouve); - miseAJourChoixResp(tCand[3]->tChoix, pos); - menuCandidat(tCand, tMax); /* Appel du menu adapté au candidat */ + aux = tCand; + while(aux != ) + //menuCandidat(tCand, tMax); /* Appel du menu adapté au candidat */ afficherCandChoix(tCand, tMax); sauvegarder(tCand, tMax); /* Sauvegarde du tableau de candidats */ } @@ -1695,4 +1645,13 @@ void menuCandidat(Candidat *tCand[], int tMax) /* Fonction affichant un menu ada 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/Commun.h b/Commun.h index f6b960a..25704de 100644 --- a/Commun.h +++ b/Commun.h @@ -104,6 +104,7 @@ typedef struct char nom[31]; char prenom[31]; float notes[4]; + float moyenne; int nombreChoix; Choix **tChoix; } Candidat; @@ -113,7 +114,7 @@ typedef struct maillonCand { Candidat *c; struct maillonCand *suiv; -} MaillonCandidat; +} MaillonCandidat, *ListeCand; typedef struct { @@ -168,10 +169,11 @@ Candidat ** creerCandidat(Candidat *tCand[], int *tMax); FileCand filenouv(void); FileCand adjq(FileCand f, Candidat *c); FileCand supt(FileCand f); +FileCand supCand(FileCand f, int numeroC); Candidat * tete(FileCand f); -int longueur(FileCand f); +int longueurFile(FileCand f); int positionFileAttente(FileCand f, int numeroC); /* Fonctions globale, menus*/ -void globale(void); +void globale2(void); void menuCandidat(Candidat *tCand[], int tMax); \ No newline at end of file diff --git a/J2sae.c b/J2sae.c index 97a6b00..cde58d9 100755 --- a/J2sae.c +++ b/J2sae.c @@ -51,6 +51,7 @@ Candidat * lireCandidat(FILE *flot) /* Fonction permettant de lire un candidat d fgets(c->prenom, 31, flot); c->prenom[strlen(c->prenom) - 1] = '\0'; fscanf(flot, "%f%f%f%f%*c", &c->notes[0], &c->notes[1], &c->notes[2], &c->notes[3]); + c->moyenne = (c->notes[0] + c->notes[1] + c->notes[2] + c->notes[3]) / 4; fscanf(flot, "%d%*c", &c->nombreChoix); c->tChoix = (Choix **)malloc(sizeof(Choix *) * c->nombreChoix); /* Allocation dynamique du tableau de pointeurs vers des structures Choix*/ if(c->tChoix == NULL) /* pour le chargement des choix du candidats */ @@ -372,83 +373,27 @@ void miseAJourChoixCand(Choix *tChoix[], int nombreChoix) /* Fontcion permettant return; } system("clear"); - if(tChoix[pos]->decisionCand == -1) /* Affichage d'un menu adapté pour chaque cas ; le candidat peut choisir entre deux option ou bien ne rien faire */ - { - 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) + 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("| 1 Accepter la proposition d'admission |\n"); + printf("| 2 Refuser 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; + tChoix[pos]->decisionCand = -1; return; } if(saisie == 3) @@ -699,6 +644,11 @@ FileCand supt(FileCand f) return f; } +FileCand supCand(FileCand f, int numeroC) +{ + +} + Candidat * tete(FileCand f) { if(vide(f)) @@ -763,17 +713,17 @@ void afficher(FileCand f) void globale(void) /* Permet de gérer l'exécution du programme */ { - int tMax, pos, trouve, i; - Candidat **tCand, c; /* Initialisation du tableau de candidats */ + int tMax, pos, trouve, i, j; + Candidat **tCand, c **aux; /* Initialisation du tableau de candidats */ tCand = chargementCandidats(&tMax); /* Remplissage du tableau par chargement */ triCandidats(tCand, tMax); /* Tri du tableau */ for(i = 0; i < tMax; i++) /* Tri du tableau choix pour chaque candidat */ { triChoix(tCand[i]->tChoix, tCand[i]->nombreChoix); } - pos = rechercherChoix(tCand[3]->tChoix, tCand[3]->nombreChoix, "Clermont-Ferrand", "Informatique", &trouve); - miseAJourChoixResp(tCand[3]->tChoix, pos); - menuCandidat(tCand, tMax); /* Appel du menu adapté au candidat */ + aux = tCand; + while(aux != ) + //menuCandidat(tCand, tMax); /* Appel du menu adapté au candidat */ afficherCandChoix(tCand, tMax); sauvegarder(tCand, tMax); /* Sauvegarde du tableau de candidats */ } diff --git a/J2sae.h b/J2sae.h index bfbb98a..a45c40b 100755 --- a/J2sae.h +++ b/J2sae.h @@ -38,6 +38,7 @@ typedef struct char nom[31]; char prenom[31]; float notes[4]; + float moyenne; int nombreChoix; Choix **tChoix; } Candidat; @@ -47,7 +48,7 @@ typedef struct maillonCand { Candidat *c; struct maillonCand *suiv; -} MaillonCandidat; +} MaillonCandidat, *ListeCand; typedef struct { @@ -102,8 +103,9 @@ Candidat ** creerCandidat(Candidat *tCand[], int *tMax); FileCand filenouv(void); FileCand adjq(FileCand f, Candidat *c); FileCand supt(FileCand f); +FileCand supCand(FileCand f, int numeroC); Candidat * tete(FileCand f); -int longueur(FileCand f); +int longueurFile(FileCand f); int positionFileAttente(FileCand f, int numeroC); /* Fonctions globale, menus*/