From abc75ca35e727e97cb3535c516d1637973b0352f Mon Sep 17 00:00:00 2001 From: Kyllian Chabanon Date: Thu, 12 Jan 2023 12:57:01 +0100 Subject: [PATCH] Ajout des fonctions de suppression et d'ajout de choix pour un candidat --- SAE.h | 2 + dptInfos.txt | 6 ++- global.c | 4 +- partie_3.c | 114 ++++++++++++++++++++++++++++++++++++++++++--------- structures.c | 13 +++--- 5 files changed, 112 insertions(+), 27 deletions(-) diff --git a/SAE.h b/SAE.h index ec98e81..e729caa 100755 --- a/SAE.h +++ b/SAE.h @@ -69,6 +69,8 @@ int nbCandidatsAttente(Etudiant *tetud[], int nbCandidats); float modifNoteMin(float noteMin[]); float modifNoteExel(float noteExel[]); int modifNbPlaces(int nbPlaces); +void ajouterCandidature(Etudiant *tetud[], int nbCandidats, VilleIUT *tiut[], int nbVillesIUT); +void supprimerCandidature(Etudiant *tetud[], int nbCandidats); // Liste Choix ListeChoix listenouvChoix(void); diff --git a/dptInfos.txt b/dptInfos.txt index 71c5532..c3642d2 100644 --- a/dptInfos.txt +++ b/dptInfos.txt @@ -3,11 +3,15 @@ Dufour Albert 19.00 4.00 16.00 3.00 -1 +2 Clermont-Ferrand Informatique 2 0 +Grenoble +Informatique +0 +0 2 Michel Jacques diff --git a/global.c b/global.c index cc1ad31..e046313 100755 --- a/global.c +++ b/global.c @@ -7,7 +7,9 @@ void global(void) Etudiant *tetud[100]; nbVilles = chargementVillesIUT(tiut); nbCandidats = chargerCandidats(tetud); - menu(tiut, &nbVilles, tetud, &nbCandidats); + //menu(tiut, &nbVilles, tetud, &nbCandidats); + ajouterCandidature(tetud, nbCandidats, tiut, nbVilles); + afficherCandidats(tetud, nbCandidats); sauvegardeVillesIUT(tiut, nbVilles); sauvegarderCandidats(tetud, nbCandidats); } diff --git a/partie_3.c b/partie_3.c index da12341..fd1e38b 100755 --- a/partie_3.c +++ b/partie_3.c @@ -82,7 +82,7 @@ int rechercheCandidat(Etudiant *tetud[], int nbCandidats, int numRecherche, bool void afficherEtudiant(Etudiant mEtudiant) { - printf("Numéro : %d\nNom : %s\nPrénom :%s\nNotes : %.2f\t%.2f\t%.2f\t%.2f\nNombre de choix : %d\n",mEtudiant.num, mEtudiant.nom, mEtudiant.prenom, mEtudiant.tabNotes[0], mEtudiant.tabNotes[1], mEtudiant.tabNotes[2], mEtudiant.tabNotes[3], mEtudiant.nbChoix); + printf("Numéro : %d\nNom : %s\nPrénom :%s\nNotes : %.2f\t%.2f\t%.2f\t%.2f\nNombre de choix : %d\n", mEtudiant.num, mEtudiant.nom, mEtudiant.prenom, mEtudiant.tabNotes[0], mEtudiant.tabNotes[1], mEtudiant.tabNotes[2], mEtudiant.tabNotes[3], mEtudiant.nbChoix); afficherChoix(mEtudiant.lChoix); printf("\n"); } @@ -130,7 +130,7 @@ void afficherCandidatsAdmis(Etudiant *tetud[], int nbCandidats) afficherEtudiant(*tetud[i]); } } -}// TODO : Mettre un message d'erreur si aucun +} // TODO : Mettre un message d'erreur si aucun void afficherCandidatsRefuses(Etudiant *tetud[], int nbCandidats) { @@ -183,11 +183,11 @@ Etudiant modifStatueCandidat(Etudiant *tetud[], int nbCandidats, float noteMin[] { for (int i = 0; i < nbCandidats; i++) { - if(tetud[i]->tabNotes[maths] >= noteMin[maths] && tetud[i]->tabNotes[francais] >= noteMin[francais] && tetud[i]->tabNotes[anglais] >= noteMin[anglais] && tetud[i]->tabNotes[spe] >= noteMin[spe] && tetud[i]->tabNotes[moy] >= noteMin[moy]) + if (tetud[i]->tabNotes[maths] >= noteMin[maths] && tetud[i]->tabNotes[francais] >= noteMin[francais] && tetud[i]->tabNotes[anglais] >= noteMin[anglais] && tetud[i]->tabNotes[spe] >= noteMin[spe] && tetud[i]->tabNotes[moy] >= noteMin[moy]) { tetud[i]->lChoix->choix.decisionAdmission = 2; } - else if(tetud[i]->tabNotes[maths] >= noteExel[maths] && tetud[i]->tabNotes[francais] >= noteExel[francais] && tetud[i]->tabNotes[anglais] >= noteExel[anglais] && tetud[i]->tabNotes[spe] >= noteExel[spe] && tetud[i]->tabNotes[moy] >= noteExel[moy]) + else if (tetud[i]->tabNotes[maths] >= noteExel[maths] && tetud[i]->tabNotes[francais] >= noteExel[francais] && tetud[i]->tabNotes[anglais] >= noteExel[anglais] && tetud[i]->tabNotes[spe] >= noteExel[spe] && tetud[i]->tabNotes[moy] >= noteExel[moy]) { tetud[i]->lChoix->choix.decisionAdmission = 1; } @@ -201,13 +201,13 @@ Etudiant modifStatueCandidat(Etudiant *tetud[], int nbCandidats, float noteMin[] int statueCandidat(Etudiant *tetud[], int nbCandidats) { - for(int i = 0; i < nbCandidats; i++) + for (int i = 0; i < nbCandidats; i++) { - if(tetud[i]->lChoix->choix.decisionAdmission == 1) + if (tetud[i]->lChoix->choix.decisionAdmission == 1) { return 1; } - else if(tetud[i]->lChoix->choix.decisionAdmission == -1) + else if (tetud[i]->lChoix->choix.decisionAdmission == -1) { return -1; } @@ -221,9 +221,9 @@ int statueCandidat(Etudiant *tetud[], int nbCandidats) int nbCandidatsAdmis(Etudiant *tetud[], int nbCandidats) { int nbAdmis = 0; - for(int i = 0; i < nbCandidats; i++) + for (int i = 0; i < nbCandidats; i++) { - if(tetud[i]->lChoix->choix.decisionAdmission == 1) + if (tetud[i]->lChoix->choix.decisionAdmission == 1) { nbAdmis++; } @@ -234,9 +234,9 @@ int nbCandidatsAdmis(Etudiant *tetud[], int nbCandidats) int nbCandidatsRefuses(Etudiant *tetud[], int nbCandidats) { int nbRefuses = 0; - for(int i = 0; i < nbCandidats; i++) + for (int i = 0; i < nbCandidats; i++) { - if(tetud[i]->lChoix->choix.decisionAdmission == -1) + if (tetud[i]->lChoix->choix.decisionAdmission == -1) { nbRefuses++; } @@ -247,9 +247,9 @@ int nbCandidatsRefuses(Etudiant *tetud[], int nbCandidats) int nbCandidatsAttente(Etudiant *tetud[], int nbCandidats) { int nbAttente = 0; - for(int i = 0; i < nbCandidats; i++) + for (int i = 0; i < nbCandidats; i++) { - if(tetud[i]->lChoix->choix.decisionAdmission == 2) + if (tetud[i]->lChoix->choix.decisionAdmission == 2) { nbAttente++; } @@ -260,9 +260,9 @@ int nbCandidatsAttente(Etudiant *tetud[], int nbCandidats) float modifNoteMin(float noteMin[]) { - for(int i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) { - printf("Entrez la note minimale pour la matiere %s (0/20, -1 pour sortir) : ", i+1); // afficher le nom de la matiere du enum + printf("Entrez la note minimale pour la matiere %s (0/20, -1 pour sortir) : ", i + 1); // afficher le nom de la matiere du enum scanf("%f", ¬eMin[i]); while (noteMin[i] < 0 || noteMin[i] > 20) { @@ -279,9 +279,9 @@ float modifNoteMin(float noteMin[]) float modifNoteExel(float noteExel[]) { - for(int i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) { - printf("Entrez la note minimale pour la matiere %s (0/20, -1 pour sortir) : ", i+1); // afficher le nom de la matiere du enum + printf("Entrez la note minimale pour la matiere %s (0/20, -1 pour sortir) : ", i + 1); // afficher le nom de la matiere du enum scanf("%f", ¬eExel[i]); while (noteExel[i] < 0 || noteExel[i] > 20) { @@ -303,13 +303,87 @@ int modifNbPlaces(int nbPlaces) return nbPlaces; } -int ajouterCandidat(Candidat *tiut[]) +/*int ajouterCandidat(Etudiant *tiut[]) { - Candidat cand; + Etudiant cand; printf("Entrez votre nom et votre prénom :\n> "); - scanf("%s%s", cand.nom, cand.prenom) + scanf("%s%s", cand.nom, cand.prenom); + printf("Entrez vos notes en : mathématiques, français, anglais et en spécialité :\n> "); + scanf("%f%f%f%f", cand.tabNotes[0], cand.tabNotes[1], cand.tabNotes[2], cand.tabNotes[3]); + printf("Entrez votre nombre de choix : "); + scanf("%d", cand.nbChoix) +}*/ + +void ajouterCandidature(Etudiant *tetud[], int nbCandidats, VilleIUT *tiut[], int nbVillesIUT) +{ + int num, posCand, posVille; + char ville[30], dept[30]; + bool trouve; + Choix c; + //! AUTHENTIFICATION + printf("Entrez votre numéro de candidat :\n> "); + scanf("%d", &num); + posCand = rechercheCandidat(tetud, nbCandidats, num, &trouve); + if (!trouve) + { + printf("Numéro de candidat non trouvé."); + return; + } + printf("Entrez la ville du département que vous souhaitez ajouter :\n> "); + scanf("%s", ville); + posVille = rechercheVille(tiut, nbVillesIUT, ville, &trouve); + if (!trouve) + { + printf("Ville non trouvée."); + return; + } + printf("Entrez le département que vous souhaitez ajouter :\n> "); + scanf("%s", dept); + rechercheDept(tiut[posVille]->ldept, dept, &trouve); + if (!trouve) + { + printf("Département non trouvé."); + return; + } + strcpy(c.ville, ville); + strcpy(c.departement, dept); + c.decisionAdmission = 0; + c.decisionCandidat = 0; + tetud[posCand]->lChoix = insererChoix(tetud[posCand]->lChoix, c); + tetud[posCand]->nbChoix++; +} + +void supprimerCandidature(Etudiant *tetud[], int nbCandidats) +{ + int num, posCand, posVille; + char ville[30], dept[30]; + bool trouve; + Choix c; + //! AUTHENTIFICATION + printf("Entrez votre numéro de candidat :\n> "); + scanf("%d", &num); + posCand = rechercheCandidat(tetud, nbCandidats, num, &trouve); + if (!trouve) + { + printf("Numéro de candidat non trouvé."); + return; + } + printf("Entrez la ville du département que vous souhaitez supprimer :\n> "); + scanf("%s", c.ville); + printf("Entrez le département que vous souhaitez supprimer :\n> "); + scanf("%s", c.departement); + trouve = rechercheChoix(tetud[posCand]->lChoix, c); + if (!trouve) + { + printf("Choix non trouvé."); + return; + } + tetud[posCand]->lChoix = supprimerChoix(tetud[posCand]->lChoix, c); + tetud[posCand]->nbChoix--; } + + // ? Comment definir la note sur 20 mise lors de l'etude du dossier ? // ? Ajouter une variable dans la structure Admission ? // ? Ou mettre la liste et la note dans un tableau ? diff --git a/structures.c b/structures.c index ea30cc1..984eff3 100755 --- a/structures.c +++ b/structures.c @@ -60,13 +60,16 @@ ListeChoix supprimerChoix(ListeChoix lc, Choix choix) if (strcmp(choix.ville, lc->choix.ville) < 0) return lc; if (strcmp(choix.ville, lc->choix.ville) == 0) + { if (strcmp(choix.departement, lc->choix.departement) == 0) - return supprimerEnTeteChoix(lc); - lc->suiv = supprimerChoix(lc->suiv, lc->choix); - return lc; + { + return supprimerEnTeteChoix(lc); + } + } + return supprimerChoix(lc->suiv, choix); } -bool rechercherChoix(ListeChoix lc, Choix choix) +bool rechercheChoix(ListeChoix lc, Choix choix) { if (videChoix(lc)) return false; @@ -75,7 +78,7 @@ bool rechercherChoix(ListeChoix lc, Choix choix) if (strcmp(choix.ville, lc->choix.ville) == 0) if (strcmp(choix.departement, lc->choix.departement) == 0) return true; - return rechercherChoix(lc->suiv, lc->choix); + return rechercheChoix(lc->suiv, lc->choix); } Choix TeteChoix(ListeChoix lc)