Ajout des structures de la fonction suppression candidat et maj de misaAJourCand

master
Johnny RATTON 2 years ago
parent d2150e4d55
commit 13a9d34ad0

@ -904,6 +904,7 @@ Candidat * lireCandidat(FILE *flot) /* Fonction permettant de lire un candidat d
fgets(c->prenom, 31, flot); fgets(c->prenom, 31, flot);
c->prenom[strlen(c->prenom) - 1] = '\0'; 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]); 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); fscanf(flot, "%d%*c", &c->nombreChoix);
c->tChoix = (Choix **)malloc(sizeof(Choix *) * c->nombreChoix); /* Allocation dynamique du tableau de pointeurs vers des structures Choix*/ 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 */ if(c->tChoix == NULL) /* pour le chargement des choix du candidats */
@ -1225,14 +1226,14 @@ void miseAJourChoixCand(Choix *tChoix[], int nombreChoix) /* Fontcion permettant
return; return;
} }
system("clear"); 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 */ if(tChoix[pos]->decisionCand == 0)
{ {
printf("Vous avez actuellement refusé la proposition d'admission de l'établissement\n\n"); printf("Vous n'avez actuellement pris aucune décision\n\n");
printf("|---------------------------------------|\n"); printf("|---------------------------------------|\n");
printf("| Que souhaitez-vous faire ? |\n"); printf("| Que souhaitez-vous faire ? |\n");
printf("|---------------------------------------|\n"); printf("|---------------------------------------|\n");
printf("| 1 Accepter la proposition d'admission |\n"); printf("| 1 Accepter la proposition d'admission |\n");
printf("| 2 Prendre un temps de réflexion |\n"); printf("| 2 Refuser la proposition d'admission |\n");
printf("| 3 Ne rien changer |\n"); printf("| 3 Ne rien changer |\n");
printf("|---------------------------------------|\n"); printf("|---------------------------------------|\n");
printf("Saisie : "); printf("Saisie : ");
@ -1244,66 +1245,10 @@ void miseAJourChoixCand(Choix *tChoix[], int nombreChoix) /* Fontcion permettant
return; return;
} }
if(saisie == 2) 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; tChoix[pos]->decisionCand = -1;
return; return;
} }
if(saisie == 2)
{
tChoix[pos]->decisionCand = 0;
return;
}
if(saisie == 3) if(saisie == 3)
{ {
return; return;
@ -1552,6 +1497,11 @@ FileCand supt(FileCand f)
return f; return f;
} }
FileCand supCand(FileCand f, int numeroC)
{
}
Candidat * tete(FileCand f) Candidat * tete(FileCand f)
{ {
if(vide(f)) if(vide(f))
@ -1616,17 +1566,17 @@ void afficher(FileCand f)
void globale(void) /* Permet de gérer l'exécution du programme */ void globale(void) /* Permet de gérer l'exécution du programme */
{ {
int tMax, pos, trouve, i; int tMax, pos, trouve, i, j;
Candidat **tCand, c; /* Initialisation du tableau de candidats */ Candidat **tCand, c **aux; /* Initialisation du tableau de candidats */
tCand = chargementCandidats(&tMax); /* Remplissage du tableau par chargement */ tCand = chargementCandidats(&tMax); /* Remplissage du tableau par chargement */
triCandidats(tCand, tMax); /* Tri du tableau */ triCandidats(tCand, tMax); /* Tri du tableau */
for(i = 0; i < tMax; i++) /* Tri du tableau choix pour chaque candidat */ for(i = 0; i < tMax; i++) /* Tri du tableau choix pour chaque candidat */
{ {
triChoix(tCand[i]->tChoix, tCand[i]->nombreChoix); triChoix(tCand[i]->tChoix, tCand[i]->nombreChoix);
} }
pos = rechercherChoix(tCand[3]->tChoix, tCand[3]->nombreChoix, "Clermont-Ferrand", "Informatique", &trouve); aux = tCand;
miseAJourChoixResp(tCand[3]->tChoix, pos); while(aux != )
menuCandidat(tCand, tMax); /* Appel du menu adapté au candidat */ //menuCandidat(tCand, tMax); /* Appel du menu adapté au candidat */
afficherCandChoix(tCand, tMax); afficherCandChoix(tCand, tMax);
sauvegarder(tCand, tMax); /* Sauvegarde du tableau de candidats */ sauvegarder(tCand, tMax); /* Sauvegarde du tableau de candidats */
} }
@ -1696,3 +1646,12 @@ void menuCandidat(Candidat *tCand[], int tMax) /* Fonction affichant un menu ada
printf("\n"); 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");
}

@ -104,6 +104,7 @@ typedef struct
char nom[31]; char nom[31];
char prenom[31]; char prenom[31];
float notes[4]; float notes[4];
float moyenne;
int nombreChoix; int nombreChoix;
Choix **tChoix; Choix **tChoix;
} Candidat; } Candidat;
@ -113,7 +114,7 @@ typedef struct maillonCand
{ {
Candidat *c; Candidat *c;
struct maillonCand *suiv; struct maillonCand *suiv;
} MaillonCandidat; } MaillonCandidat, *ListeCand;
typedef struct typedef struct
{ {
@ -168,10 +169,11 @@ Candidat ** creerCandidat(Candidat *tCand[], int *tMax);
FileCand filenouv(void); FileCand filenouv(void);
FileCand adjq(FileCand f, Candidat *c); FileCand adjq(FileCand f, Candidat *c);
FileCand supt(FileCand f); FileCand supt(FileCand f);
FileCand supCand(FileCand f, int numeroC);
Candidat * tete(FileCand f); Candidat * tete(FileCand f);
int longueur(FileCand f); int longueurFile(FileCand f);
int positionFileAttente(FileCand f, int numeroC); int positionFileAttente(FileCand f, int numeroC);
/* Fonctions globale, menus*/ /* Fonctions globale, menus*/
void globale(void); void globale2(void);
void menuCandidat(Candidat *tCand[], int tMax); void menuCandidat(Candidat *tCand[], int tMax);

@ -51,6 +51,7 @@ Candidat * lireCandidat(FILE *flot) /* Fonction permettant de lire un candidat d
fgets(c->prenom, 31, flot); fgets(c->prenom, 31, flot);
c->prenom[strlen(c->prenom) - 1] = '\0'; 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]); 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); fscanf(flot, "%d%*c", &c->nombreChoix);
c->tChoix = (Choix **)malloc(sizeof(Choix *) * c->nombreChoix); /* Allocation dynamique du tableau de pointeurs vers des structures Choix*/ 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 */ if(c->tChoix == NULL) /* pour le chargement des choix du candidats */
@ -372,14 +373,14 @@ void miseAJourChoixCand(Choix *tChoix[], int nombreChoix) /* Fontcion permettant
return; return;
} }
system("clear"); 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 */ if(tChoix[pos]->decisionCand == 0)
{ {
printf("Vous avez actuellement refusé la proposition d'admission de l'établissement\n\n"); printf("Vous n'avez actuellement pris aucune décision\n\n");
printf("|---------------------------------------|\n"); printf("|---------------------------------------|\n");
printf("| Que souhaitez-vous faire ? |\n"); printf("| Que souhaitez-vous faire ? |\n");
printf("|---------------------------------------|\n"); printf("|---------------------------------------|\n");
printf("| 1 Accepter la proposition d'admission |\n"); printf("| 1 Accepter la proposition d'admission |\n");
printf("| 2 Prendre un temps de réflexion |\n"); printf("| 2 Refuser la proposition d'admission |\n");
printf("| 3 Ne rien changer |\n"); printf("| 3 Ne rien changer |\n");
printf("|---------------------------------------|\n"); printf("|---------------------------------------|\n");
printf("Saisie : "); printf("Saisie : ");
@ -391,66 +392,10 @@ void miseAJourChoixCand(Choix *tChoix[], int nombreChoix) /* Fontcion permettant
return; return;
} }
if(saisie == 2) 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; tChoix[pos]->decisionCand = -1;
return; return;
} }
if(saisie == 2)
{
tChoix[pos]->decisionCand = 0;
return;
}
if(saisie == 3) if(saisie == 3)
{ {
return; return;
@ -699,6 +644,11 @@ FileCand supt(FileCand f)
return f; return f;
} }
FileCand supCand(FileCand f, int numeroC)
{
}
Candidat * tete(FileCand f) Candidat * tete(FileCand f)
{ {
if(vide(f)) if(vide(f))
@ -763,17 +713,17 @@ void afficher(FileCand f)
void globale(void) /* Permet de gérer l'exécution du programme */ void globale(void) /* Permet de gérer l'exécution du programme */
{ {
int tMax, pos, trouve, i; int tMax, pos, trouve, i, j;
Candidat **tCand, c; /* Initialisation du tableau de candidats */ Candidat **tCand, c **aux; /* Initialisation du tableau de candidats */
tCand = chargementCandidats(&tMax); /* Remplissage du tableau par chargement */ tCand = chargementCandidats(&tMax); /* Remplissage du tableau par chargement */
triCandidats(tCand, tMax); /* Tri du tableau */ triCandidats(tCand, tMax); /* Tri du tableau */
for(i = 0; i < tMax; i++) /* Tri du tableau choix pour chaque candidat */ for(i = 0; i < tMax; i++) /* Tri du tableau choix pour chaque candidat */
{ {
triChoix(tCand[i]->tChoix, tCand[i]->nombreChoix); triChoix(tCand[i]->tChoix, tCand[i]->nombreChoix);
} }
pos = rechercherChoix(tCand[3]->tChoix, tCand[3]->nombreChoix, "Clermont-Ferrand", "Informatique", &trouve); aux = tCand;
miseAJourChoixResp(tCand[3]->tChoix, pos); while(aux != )
menuCandidat(tCand, tMax); /* Appel du menu adapté au candidat */ //menuCandidat(tCand, tMax); /* Appel du menu adapté au candidat */
afficherCandChoix(tCand, tMax); afficherCandChoix(tCand, tMax);
sauvegarder(tCand, tMax); /* Sauvegarde du tableau de candidats */ sauvegarder(tCand, tMax); /* Sauvegarde du tableau de candidats */
} }

@ -38,6 +38,7 @@ typedef struct
char nom[31]; char nom[31];
char prenom[31]; char prenom[31];
float notes[4]; float notes[4];
float moyenne;
int nombreChoix; int nombreChoix;
Choix **tChoix; Choix **tChoix;
} Candidat; } Candidat;
@ -47,7 +48,7 @@ typedef struct maillonCand
{ {
Candidat *c; Candidat *c;
struct maillonCand *suiv; struct maillonCand *suiv;
} MaillonCandidat; } MaillonCandidat, *ListeCand;
typedef struct typedef struct
{ {
@ -102,8 +103,9 @@ Candidat ** creerCandidat(Candidat *tCand[], int *tMax);
FileCand filenouv(void); FileCand filenouv(void);
FileCand adjq(FileCand f, Candidat *c); FileCand adjq(FileCand f, Candidat *c);
FileCand supt(FileCand f); FileCand supt(FileCand f);
FileCand supCand(FileCand f, int numeroC);
Candidat * tete(FileCand f); Candidat * tete(FileCand f);
int longueur(FileCand f); int longueurFile(FileCand f);
int positionFileAttente(FileCand f, int numeroC); int positionFileAttente(FileCand f, int numeroC);
/* Fonctions globale, menus*/ /* Fonctions globale, menus*/

Loading…
Cancel
Save