diff --git a/Commun.c b/Commun.c index 5b35f87..572191f 100644 --- a/Commun.c +++ b/Commun.c @@ -870,7 +870,6 @@ Candidat ** chargementCandidats(int *tMax) /* Permet de charger le contenu du fi exit(1); } fscanf(flot, "%d", tMax); /* Lecture du nombre de candidats pour déterminer la taille physique du tableau */ - printf("tMax : %d\n", *tMax); tCand = (Candidat **)malloc(sizeof(Candidat *) * (*tMax)); /* Allocation dynamique du tableau de candidats*/ if(tCand == NULL) { @@ -976,9 +975,9 @@ void afficherChoix(Choix *c) /* Fonction permettant d'afficher les informations void afficherCandidat(Candidat *c) /* Fonction permettant d'afficher les informations d'un candidat donné en paramètre */ { - printf("|------------------------------------------------------------------------------------------------------------|\n"); + printf("|---------------------------------------------------------------------------------------------------------|\n"); printf("| %-4d | %-32s | %-32s | %2.2f | %2.2f | %2.2f | %2.2f |\n", c->numeroC, c->nom, c->prenom, c->notes[0], c->notes[1], c->notes[2], c->notes[3]); - printf("|------------------------------------------------------------------------------------------------------------|\n"); + printf("|---------------------------------------------------------------------------------------------------------|\n"); } void afficherCandChoix(Candidat *tCand[],int tMax) /* Fonction permettant d'afficher tous les candidats du tableau tCand ainsi que tous leurs choix */ @@ -986,8 +985,8 @@ void afficherCandChoix(Candidat *tCand[],int tMax) /* Fonction permettant d'aff 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"); @@ -1080,7 +1079,6 @@ int plusGrandCand(Candidat *tCand[], int tMax) /* Fonction permettant de trouver void echangerCand(Candidat *tCand[], int i, int j) /* Fonction permettant d'échanger deux éléments dans un tableau de candidats*/ { - printf("Echange\n"); Candidat *aux; aux = tCand[i]; tCand[i] = tCand[j]; @@ -1310,6 +1308,132 @@ void miseAJourChoixCand(Choix *tChoix[], int nombreChoix) /* Fontcion permettant } } + +void miseAJourChoixResp(Choix *tChoix[], int pos) /* Fontcion permettant de mettre à jour la décision d'un responsable d'admission concernant un candidat */ +{ + int saisie; + system("clear"); + if(tChoix[pos]->decisionCand == 0) /* Affichage d'un menu adapté pour chaque cas ; le candidat peut choisir entre deux option ou bien ne rien faire */ + { + printf("Votre décision est actuellement en attente\n\n"); + printf("|---------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|---------------------------------------|\n"); + printf("| 1 Accepter la demande d'admission |\n"); + printf("| 2 Mettre sur liste d'attente |\n"); + printf("| 3 Refuser la demande d'admission |\n"); + printf("| 4 Ne rien changer |\n"); + printf("|---------------------------------------|\n"); + printf("Saisie : "); + scanf("%d%*c", &saisie); + printf("\n"); + if(saisie == 1) + { + tChoix[pos]->decisionResp = 1; + return; + } + if(saisie == 2) + { + tChoix[pos]->decisionCand = 2; + return; + } + if(saisie == 3) + { + tChoix[pos]->decisionCand = -1; + return; + } + if(saisie == 4) + { + return; + } + } + if(tChoix[pos]->decisionCand == 2) /* Affichage d'un menu adapté pour chaque cas ; le candidat peut choisir entre deux option ou bien ne rien faire */ + { + printf("Votre décision est actuellement en attente\n\n"); + printf("|---------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|---------------------------------------|\n"); + printf("| 1 Accepter la demande d'admission |\n"); + printf("| 2 Refuser la demande d'admission |\n"); + printf("| 3 Ne rien changer |\n"); + printf("|---------------------------------------|\n"); + printf("Saisie : "); + scanf("%d%*c", &saisie); + printf("\n"); + if(saisie == 1) + { + tChoix[pos]->decisionResp = 1; + return; + } + if(saisie == 2) + { + tChoix[pos]->decisionCand = -1; + return; + } + if(saisie == 3) + { + return; + } + } +} + + +Candidat ** creerCandidat(Candidat *tCand[], int *tMax) +{ + int pos, trouve, i, numeroC; + char nom[31], prenom[31]; + float notes[4]; + Candidat *c; + printf("Quel est votre numéro de candidat ?\nSaisie : "); /* Demande à l'utilisateur le numéro du candidat pour l'insertion */ + scanf("%d%*c", &numeroC); + printf("\n"); + pos = rechercherCandidat(tCand, *tMax, numeroC, &trouve); /* Vérifie que le numero de candidat n'existe pas déjà */ + if(trouve == 1) + { + printf("Erreur, votre numéro de candidat existe déjà dans la base de données\n"); + return tCand; + } + c = (Candidat *)malloc(sizeof(Candidat)); /* Allocation dynamique du candidat à insérer */ + if(c == NULL) + { + printf("Erreur d'allocation mémoire lors de l'insertion du candidat\n"); + return tCand; + } + printf("Quel est votre nom ?\n"); + scanf("%s%*c", nom); + printf("\n"); + printf("Quel est votre prenom ?\n"); + scanf("%s%*c", prenom); + printf("\n"); + printf("Quel est votre moyenne de maths ?\n"); + scanf("%f%*c", ¬es[0]); + printf("\n"); + printf("Quel est votre moyenne de français ?\n"); + scanf("%f%*c", ¬es[1]); + printf("\n"); + printf("Quel est votre moyenne d'anglais ?\n"); + scanf("%f%*c", ¬es[2]); + printf("\n"); + printf("Quel est votre moyenne de spécialité ?\n"); + scanf("%f%*c", ¬es[3]); + printf("\n"); + c->numeroC = numeroC; + strcpy(c->nom, nom); /* Ajout des valeurs dans le candidat à insérer */ + strcpy(c->prenom, prenom); + c->notes[0] = notes[0]; + c->notes[1] = notes[1]; + c->notes[2] = notes[2]; + c->notes[3] = notes[3]; + tCand = reallocationCand(tCand, *tMax); /* Réallocation du tableau de candidats pour ajouter une place */ + for(i = *tMax; i > pos; i--) /* Décalage à droite des éléments du tableau à partir de la position d'insertion */ + { + tCand[i] = tCand[i - 1]; + } + tCand[pos] = c; /* Ajout du candidat dans le tableau */ + *tMax = *tMax + 1; /* Mise à jour de la taille physique du tableau */ + return tCand; +} + /*********************************** Fonctions de recherche *************************************************/ /************************************************************************************************************/ /************************************************************************************************************/ @@ -1387,7 +1511,10 @@ void globale(void) /* Permet de gérer l'exécution du programme */ { 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 */ + afficherCandChoix(tCand, tMax); sauvegarder(tCand, tMax); /* Sauvegarde du tableau de candidats */ } diff --git a/Commun.h b/Commun.h index 92f4b98..10478c9 100644 --- a/Commun.h +++ b/Commun.h @@ -147,6 +147,8 @@ 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); +void miseAJourChoixResp(Choix *tChoix[], int pos); +Candidat ** creerCandidat(Candidat *tCand[], int *tMax); /* Fonctions globale, menus*/ void globale2(void); diff --git a/J2sae.c b/J2sae.c index 7ac799e..7bf1543 100755 --- a/J2sae.c +++ b/J2sae.c @@ -17,7 +17,6 @@ Candidat ** chargementCandidats(int *tMax) /* Permet de charger le contenu du fi exit(1); } fscanf(flot, "%d", tMax); /* Lecture du nombre de candidats pour déterminer la taille physique du tableau */ - printf("tMax : %d\n", *tMax); tCand = (Candidat **)malloc(sizeof(Candidat *) * (*tMax)); /* Allocation dynamique du tableau de candidats*/ if(tCand == NULL) { @@ -123,9 +122,9 @@ void afficherChoix(Choix *c) /* Fonction permettant d'afficher les informations void afficherCandidat(Candidat *c) /* Fonction permettant d'afficher les informations d'un candidat donné en paramètre */ { - printf("|------------------------------------------------------------------------------------------------------------|\n"); + printf("|---------------------------------------------------------------------------------------------------------|\n"); printf("| %-4d | %-32s | %-32s | %2.2f | %2.2f | %2.2f | %2.2f |\n", c->numeroC, c->nom, c->prenom, c->notes[0], c->notes[1], c->notes[2], c->notes[3]); - printf("|------------------------------------------------------------------------------------------------------------|\n"); + printf("|---------------------------------------------------------------------------------------------------------|\n"); } void afficherCandChoix(Candidat *tCand[],int tMax) /* Fonction permettant d'afficher tous les candidats du tableau tCand ainsi que tous leurs choix */ @@ -133,8 +132,8 @@ void afficherCandChoix(Candidat *tCand[],int tMax) /* Fonction permettant d'aff 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"); @@ -227,7 +226,6 @@ int plusGrandCand(Candidat *tCand[], int tMax) /* Fonction permettant de trouver void echangerCand(Candidat *tCand[], int i, int j) /* Fonction permettant d'échanger deux éléments dans un tableau de candidats*/ { - printf("Echange\n"); Candidat *aux; aux = tCand[i]; tCand[i] = tCand[j]; @@ -457,6 +455,132 @@ void miseAJourChoixCand(Choix *tChoix[], int nombreChoix) /* Fontcion permettant } } + +void miseAJourChoixResp(Choix *tChoix[], int pos) /* Fontcion permettant de mettre à jour la décision d'un responsable d'admission concernant un candidat */ +{ + int saisie; + system("clear"); + if(tChoix[pos]->decisionCand == 0) /* Affichage d'un menu adapté pour chaque cas ; le candidat peut choisir entre deux option ou bien ne rien faire */ + { + printf("Votre décision est actuellement en attente\n\n"); + printf("|---------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|---------------------------------------|\n"); + printf("| 1 Accepter la demande d'admission |\n"); + printf("| 2 Mettre sur liste d'attente |\n"); + printf("| 3 Refuser la demande d'admission |\n"); + printf("| 4 Ne rien changer |\n"); + printf("|---------------------------------------|\n"); + printf("Saisie : "); + scanf("%d%*c", &saisie); + printf("\n"); + if(saisie == 1) + { + tChoix[pos]->decisionResp = 1; + return; + } + if(saisie == 2) + { + tChoix[pos]->decisionCand = 2; + return; + } + if(saisie == 3) + { + tChoix[pos]->decisionCand = -1; + return; + } + if(saisie == 4) + { + return; + } + } + if(tChoix[pos]->decisionCand == 2) /* Affichage d'un menu adapté pour chaque cas ; le candidat peut choisir entre deux option ou bien ne rien faire */ + { + printf("Votre décision est actuellement en attente\n\n"); + printf("|---------------------------------------|\n"); + printf("| Que souhaitez-vous faire ? |\n"); + printf("|---------------------------------------|\n"); + printf("| 1 Accepter la demande d'admission |\n"); + printf("| 2 Refuser la demande d'admission |\n"); + printf("| 3 Ne rien changer |\n"); + printf("|---------------------------------------|\n"); + printf("Saisie : "); + scanf("%d%*c", &saisie); + printf("\n"); + if(saisie == 1) + { + tChoix[pos]->decisionResp = 1; + return; + } + if(saisie == 2) + { + tChoix[pos]->decisionCand = -1; + return; + } + if(saisie == 3) + { + return; + } + } +} + + +Candidat ** creerCandidat(Candidat *tCand[], int *tMax) +{ + int pos, trouve, i, numeroC; + char nom[31], prenom[31]; + float notes[4]; + Candidat *c; + printf("Quel est votre numéro de candidat ?\nSaisie : "); /* Demande à l'utilisateur le numéro du candidat pour l'insertion */ + scanf("%d%*c", &numeroC); + printf("\n"); + pos = rechercherCandidat(tCand, *tMax, numeroC, &trouve); /* Vérifie que le numero de candidat n'existe pas déjà */ + if(trouve == 1) + { + printf("Erreur, votre numéro de candidat existe déjà dans la base de données\n"); + return tCand; + } + c = (Candidat *)malloc(sizeof(Candidat)); /* Allocation dynamique du candidat à insérer */ + if(c == NULL) + { + printf("Erreur d'allocation mémoire lors de l'insertion du candidat\n"); + return tCand; + } + printf("Quel est votre nom ?\n"); + scanf("%s%*c", nom); + printf("\n"); + printf("Quel est votre prenom ?\n"); + scanf("%s%*c", prenom); + printf("\n"); + printf("Quel est votre moyenne de maths ?\n"); + scanf("%f%*c", ¬es[0]); + printf("\n"); + printf("Quel est votre moyenne de français ?\n"); + scanf("%f%*c", ¬es[1]); + printf("\n"); + printf("Quel est votre moyenne d'anglais ?\n"); + scanf("%f%*c", ¬es[2]); + printf("\n"); + printf("Quel est votre moyenne de spécialité ?\n"); + scanf("%f%*c", ¬es[3]); + printf("\n"); + c->numeroC = numeroC; + strcpy(c->nom, nom); /* Ajout des valeurs dans le candidat à insérer */ + strcpy(c->prenom, prenom); + c->notes[0] = notes[0]; + c->notes[1] = notes[1]; + c->notes[2] = notes[2]; + c->notes[3] = notes[3]; + tCand = reallocationCand(tCand, *tMax); /* Réallocation du tableau de candidats pour ajouter une place */ + for(i = *tMax; i > pos; i--) /* Décalage à droite des éléments du tableau à partir de la position d'insertion */ + { + tCand[i] = tCand[i - 1]; + } + tCand[pos] = c; /* Ajout du candidat dans le tableau */ + *tMax = *tMax + 1; /* Mise à jour de la taille physique du tableau */ + return tCand; +} + /*********************************** Fonctions de recherche *************************************************/ /************************************************************************************************************/ /************************************************************************************************************/ @@ -534,7 +658,10 @@ void globale(void) /* Permet de gérer l'exécution du programme */ { 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 */ + afficherCandChoix(tCand, tMax); sauvegarder(tCand, tMax); /* Sauvegarde du tableau de candidats */ } diff --git a/J2sae.h b/J2sae.h index 516de79..e77581e 100755 --- a/J2sae.h +++ b/J2sae.h @@ -81,6 +81,8 @@ 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); +void miseAJourChoixResp(Choix *tChoix[], int pos); +Candidat ** creerCandidat(Candidat *tCand[], int *tMax); /* Fonctions globale, menus*/ void globale(void);