diff --git a/.gitignore b/.gitignore index ec70424..ef51d06 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ *.i*86 *.x86_64 *.hex +SAE # Debug files *.dSYM/ @@ -59,7 +60,8 @@ dkms.conf .LSOverride # Icon must end with two \r -Icon +Icon + # Thumbnails ._* diff --git a/Etudiants.bin b/Etudiants.bin new file mode 120000 index 0000000..aabe1e1 --- /dev/null +++ b/Etudiants.bin @@ -0,0 +1 @@ +src/DataBase/Etudiants.bin \ No newline at end of file diff --git a/Input b/Input new file mode 100644 index 0000000..524f7e6 --- /dev/null +++ b/Input @@ -0,0 +1,5 @@ +A + + +6 +Yann diff --git a/Makefile b/Makefile index d65dfa5..1295db6 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,14 @@ -PHONY : clean doc all -all : prog +.PHONY: clean doc all + +all : prog EXE prog : make -C src all +EXE : + rm -f SAE + gcc -g -o SAE src/saeMain.o src/annexe/saeAnnexe.o src/partie1/saeP1.o src/partie2/saeP2.o src/partie3/saeP3.o src/partie4/saeP4.o + doc : make -C src doc diff --git a/src/Makefile b/src/Makefile index cbe6040..3c10091 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,16 +1,13 @@ -all : SAE +.PHONY : all doc clean lib -.PHONY : all doc clean +all : saeMain.o lib -lib : annexe/saeAnnexe.o partie1/saeP1.o partie2/saeP2.o partie3/saeP3.o partie4/saeP4.o - make -C annexe all - make -C partie1 all - make -C partie2 all - make -C partie3 all - make -C partie4 all - -SAE : saeMain.o lib - gcc -o ../SAE saeMain.o annexe/saeAnnexe.o partie1/saeP1.o partie2/saeP2.o partie3/saeP3.o partie4/saeP4.o +lib : + make -C annexe + make -C partie1 + make -C partie2 + make -C partie3 + make -C partie4 saeMain.o : saeMain.c gcc -Wall -c saeMain.c @@ -27,4 +24,4 @@ clean : make -C partie1 clean make -C partie2 clean make -C partie3 clean - make -C partie4 clean \ No newline at end of file + make -C partie4 clean diff --git a/src/annexe/Makefile b/src/annexe/Makefile index 6f41ebb..b9bd736 100644 --- a/src/annexe/Makefile +++ b/src/annexe/Makefile @@ -1,3 +1,7 @@ + +CC = gcc +CCOPTS = -Wall + all : saeAnnexe.o saeAnnexe.o : saeAnnexe.c saeAnnexe.h diff --git a/src/annexe/saeAnnexe.c b/src/annexe/saeAnnexe.c index 28a3b1d..e4ea068 100644 --- a/src/annexe/saeAnnexe.c +++ b/src/annexe/saeAnnexe.c @@ -15,6 +15,7 @@ void menu(void){ printf("C : Consultation.\n"); printf("A : Administrateur.\n"); printf("S : Sauvegarder.\n\n"); + printf("Q : Quitter.\n\n"); printf("#--------------------------------------------------------------------#\n\n"); printf("Choisissez votre session : "); } @@ -59,6 +60,7 @@ int loadIUT(VilleIUT** tiut){ return tlogi; } +<<<<<<< HEAD void saveIUT(VilleIUT** tiut, int tlogi){ FILE* f=fopen("Etudiants.bin","rb"); if(f==NULL){ @@ -85,12 +87,14 @@ void saveIUT(VilleIUT** tiut, int tlogi){ } int rechercheTabPtVilleIUT(VilleIUT* tab[],int lTab,char* mot){ +======= +int rechercheIUT(VilleIUT* tab[],int lTab,char mot[]){ +>>>>>>> d1df1ce5e50feb147850be94e120a32207905272 if(!lTab){ - fprintf(stderr,"Erreur, Pas d'éléments dans le tableau !"); return -1; } for(int i=0; iVille==mot) return i; + if(!strcmp(tab[i]->Ville,mot)) return i; } return -1; } diff --git a/src/annexe/saeAnnexe.h b/src/annexe/saeAnnexe.h index d6854fe..8b0a66a 100644 --- a/src/annexe/saeAnnexe.h +++ b/src/annexe/saeAnnexe.h @@ -33,7 +33,7 @@ int loadIUT(VilleIUT** tiut); // // void saveIUT(VilleIUT** tiut, int tlogi); // // -int rechercheTabPtVilleIUT(VilleIUT* tab[],int lTab,char* mot); // +int rechercheIUT(VilleIUT* tab[],int lTab,char mot[]); // // // // @@ -72,4 +72,4 @@ void vider_file(File f); // // // // void reset(void); // -//--------------------------------------------------------------// \ No newline at end of file +//--------------------------------------------------------------// diff --git a/src/partie1/Makefile b/src/partie1/Makefile index 7b12495..b677515 100644 --- a/src/partie1/Makefile +++ b/src/partie1/Makefile @@ -1,7 +1,7 @@ all : saeP1.o saeP1.o : saeP1.c saeP1.h - gcc -Wall -c saeP1.c + gcc -Wall -Werror -Wextra -g -c saeP1.c doc : saeP1.h doxygen diff --git a/src/partie1/saeP1.c b/src/partie1/saeP1.c index e9de19f..857303d 100644 --- a/src/partie1/saeP1.c +++ b/src/partie1/saeP1.c @@ -8,9 +8,11 @@ //Partie Consultant. -void MenuUser(VilleIUT* lvIUT[],int tlogi) +void menuUser(VilleIUT* lvIUT[],int tlogi) { - int intUserEntry=0; + int quit=0; + while(!quit) + { printf("#--------------------------------------------------------------------#\n"); printf("| |\n"); printf("| SAE S1.02 |\n"); @@ -21,33 +23,60 @@ void MenuUser(VilleIUT* lvIUT[],int tlogi) printf("2 : Afficher tout les départements de chaques IUT\n"); printf("3 : Afficher le nombre de place en première année d'un IUT précis avec un département précis\n"); printf("4 : Rechercher les IUTs possèdant un département précis.\n"); + /*if(CandidOpen) + { + printf("5 : Candidater"); + }*/ printf("9 : Revenir à l'écran de sélection du profil.\n\n"); printf("#--------------------------------------------------------------------#\n\n"); - while(intUserEntry!=9) - { - printf("Choisissez l'action que vous voulez exécuter : "); - if (!(scanf("%d",intUserEntry)))printf("Entrée innexacte. Veuillez réessayer"); - if (intUserEntry==1) SearchCityWithIUT(lvIUT,tlogi); - if (intUserEntry==2) DepEachIUT(lvIUT,tlogi); - if (intUserEntry==3) SearchPlaceFromDepInIUT(lvIUT,tlogi); - if (intUserEntry==4) SearchIUTFromDep(lvIUT,tlogi); - if (intUserEntry==9) printf("Sortie en cours.\n"); - else printf("Entrée innexacte. Veuillez réessayer"); + printf("Choisissez l'action que vous voulez exécuter : "); + int act; + scanf("%d",&act); + switch(act){ + case 1: + SearchCityWithIUT(lvIUT,tlogi); + reset(); + break; + case 2: + DepEachIUT(lvIUT,tlogi); + reset(); + break; + case 3: + SearchPlaceFromDepInIUT(lvIUT,tlogi); + reset(); + break; + case 4: + SearchIUTFromDep(lvIUT,tlogi); + reset(); + break; + case 5: + //candidater(......); + reset(); + break; + case 9: + quit=1; + reset(); + + } } } void SearchCityWithIUT(VilleIUT* lvIUT[], int tlogi) { - for (int i=0;iVille); + for (int i=0;iVille); } void DepEachIUT(VilleIUT* lvIUT[], int tlogi) { for (int i=0;iVille); + printf("\n - %s :",lvIUT[i]->Ville); MaillonDep* MaillonAct=lvIUT[i]->ldept; - while (MaillonAct!=NULL) printf("\t-%s\n",MaillonAct->departement); + while (MaillonAct!=NULL) + { + printf("\t-%s\n",MaillonAct->departement); + MaillonAct=MaillonAct->suivant; + } } } @@ -56,118 +85,129 @@ void SearchPlaceFromDepInIUT(VilleIUT* lvIUT[],int tlogi) char sVille[31]; char sDep[31]; int boolF=0, i; - printf("Entrez le nom de la ville contenant le département recherché :\n"); + printf("\nEntrez le nom de la ville contenant le département recherché :\n"); scanf("%s",sVille); - printf("Département y étant disponible :\n"); for (i=0;iVille==sVille) + if (!strcmp(lvIUT[i]->Ville,sVille)) { + printf("\nDépartement y étant disponible :\n"); MaillonDep* MaillonAct=lvIUT[i]->ldept; - while (MaillonAct!=NULL) printf("%s",MaillonAct->departement); + while (MaillonAct!=NULL) + { + printf("\t-%s\n",MaillonAct->departement); + MaillonAct=MaillonAct->suivant; + } boolF=1; - MaillonAct=MaillonAct->suivant; break; } } if (!boolF) { - printf("La ville n'est pas dans la liste.\nMerci de vérifier l'orthographe.\n"); + printf("\nLa ville n'est pas dans la liste.\nMerci de vérifier l'orthographe.\n"); return; } - printf("Entrez le nom du département dont vous souhaitez connaitre le nombre de place\n"); + printf("\nEntrez le nom du département dont vous souhaitez connaitre le nombre de place\n"); scanf("%s",sDep); MaillonDep* MaillonAct=lvIUT[i]->ldept; while (MaillonAct!=NULL) { - if(MaillonAct->departement==sDep) + if(!strcmp(MaillonAct->departement,sDep)) { - printf("Nombre de place : %d\n",MaillonAct->nbp); + printf("\nNombre de place : %d\n",MaillonAct->nbp); return; } MaillonAct=MaillonAct->suivant; } - printf("Le département n'est pas dans la liste.\nMerci de vérifier l'orthographe.\n"); + printf("\nLe département n'est pas dans la liste.\nMerci de vérifier l'orthographe.\n"); } void SearchIUTFromDep(VilleIUT* lvIUT[],int tlogi) { char sDep[31]; - printf("Merci de renseignez le département dont vous cherchez les IUTs :\n"); + printf("\nMerci de renseignez le département dont vous cherchez les IUTs :\n"); scanf("%s",sDep); - + printf("\nVoici la liste des IUTs contenant le département mentionné :\n\n"); for (int i=0;ildept; - if(MaillonAct->departement==sDep) printf("%s",lvIUT[i]->Ville); + while(MaillonAct!=NULL){ + if(!strcmp(MaillonAct->departement,sDep)) printf("\t-%s\n",lvIUT[i]->Ville); + MaillonAct=MaillonAct->suivant; + } } } //Partie Administrateur. -void menuAdmin(VilleIUT* tiut[],int tlogi){ - int quit=0; - while(!quit){ - printf("#--------------------------------------------------------------------#\n"); - printf("| |\n"); - printf("| SAE S1.02 |\n"); - printf("| |\n"); - printf("#--------------------------------------------------------------------#\n\n"); - printf("Codes correspondant aux différentes actions :\n\n"); - printf("1 : Modifier le nombre de places dans un département.\n"); - printf("2 : Créer un département dans un IUT.\n"); - printf("3 : Supprimer un département d’un IUT.\n"); - printf("4 : Lancer et arrêter la phase de candidature.\n"); - printf("5 : Modifier le nom d'un responsable de département.\n"); - printf("9 : Revenir à l'écran de sélection du profil.\n\n"); - printf("#--------------------------------------------------------------------#\n\n"); - printf("Choisissez l'action que vous voulez exécuter : "); - int act; - scanf("%d",&act); - switch(act){ - case 1: - modifPlaces(tiut,tlogi); - reset(); - break; - case 2: - creerDep(tiut,tlogi); - reset(); - break; - case 3: - supprimerDep(tiut,tlogi); - reset(); - break; - case 4: - //gestionPhaseCandidatures(); A Faire (Partie 2). - reset(); - break; - case 5: - modifNomResponsable(tiut,tlogi); - reset(); - break; - case 9: - quit=1; - reset(); - } - } +void menuAdmin(VilleIUT* tiut[],int *tlogi){ + int quit=0; + while(!quit){ + printf("#--------------------------------------------------------------------#\n"); + printf("| |\n"); + printf("| SAE S1.02 |\n"); + printf("| |\n"); + printf("#--------------------------------------------------------------------#\n\n"); + printf("Codes correspondant aux différentes actions :\n\n"); + printf("1 : Modifier le nombre de places dans un département.\n"); + printf("2 : Créer un département dans un IUT.\n"); + printf("3 : Supprimer un département d’un IUT.\n"); + printf("4 : Lancer et arrêter la phase de candidature.\n"); + printf("5 : Modifier le nom d'un responsable de département.\n"); + printf("6 : Créer un IUT.\n"); + printf("9 : Revenir à l'écran de sélection du profil.\n\n"); + printf("#--------------------------------------------------------------------#\n\n"); + printf("Choisissez l'action que vous voulez exécuter : "); + int act; + scanf("%d",&act); + switch(act){ + case 1: + modifPlaces(tiut,*tlogi); + reset(); + break; + case 2: + creerDep(tiut,*tlogi); + reset(); + break; + case 3: + supprimerDep(tiut,*tlogi); + reset(); + break; + case 4: + //gestionPhaseCandidatures(); A Faire (Partie 2). + reset(); + break; + case 5: + modifNomResponsable(tiut,*tlogi); + reset(); + break; + case 6: + creerIUT(tiut,tlogi); + reset(); + break; + case 9: + quit=1; + reset(); + } + } } void modifPlaces(VilleIUT* tiut[],int tlogi){ - printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):"); + printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner): "); char ville[31]; - scanf("%*c%s",&ville); + scanf("%s",ville); if(ville[0]=='Q' && ville[1]=='\0') return; - int noVille=rechercheTabPtVilleIUT(tiut,tlogi,ville); - if(noVille<=0){ + int noVille=rechercheIUT(tiut,tlogi,ville); + if(noVille<0){ fprintf(stderr,"\nVille non existante !\n"); return; } VilleIUT* v=tiut[noVille]; - printf("\n\nEntrez le département à modifier:"); + printf("\n\nEntrez le département à modifier :"); char dep[31]; - scanf("%*c%s",&dep); - if(!existeDep(tiut->ldept,dep)){ + scanf("%s",dep); + if(!existeDep(v->ldept,dep)){ fprintf(stderr,"\nDépartement non existant !\n"); return; } @@ -182,53 +222,61 @@ void modifPlaces(VilleIUT* tiut[],int tlogi){ } void creerDep(VilleIUT* tiut[],int tlogi){ - printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):"); + printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner): "); char ville[31]; - scanf("%*c%s",&ville); + scanf("%s",ville); if(ville[0]=='Q' && ville[1]=='\0') return; - int noVille=rechercheTabPtVilleIUT(tiut,tlogi,ville); - if(noVille<=0){ + int noVille=rechercheIUT(tiut,tlogi,ville); + if(noVille<0){ fprintf(stderr,"\nVille non existante !\n"); return; } VilleIUT* v=tiut[noVille]; - MaillonDep* m=v->ldept; - while(m->suivant!=NULL) m=m->suivant; - m->suivant=(MaillonDep*)malloc(sizeof(MaillonDep)); - if(m->suivant==NULL){ - perror("malloc"); - exit(errno); + int ck=0; + if(v->ldept==NULL){ + ck=1; + v->ldept=(MaillonDep*)malloc(sizeof(MaillonDep)); + if(v->ldept==NULL){ + perror("malloc"); + exit(errno); + } } - m=m->suivant; - printf("\n\nEntrez le nom du département à créer :"); - char dep[31]; - scanf("%*c%s",&dep); - strcpy(m->departement,dep); - printf("\n\nEntrez le nombre de places disponibles dans le département :"); + MaillonDep* m=v->ldept; + if(!ck){ + while(m->suivant!=NULL) m=m->suivant; + m->suivant=(MaillonDep*)malloc(sizeof(MaillonDep)); + if(m->suivant==NULL){ + perror("malloc"); + exit(errno); + } + m=m->suivant; + } + printf("\n\nEntrez le nom du département à créer : "); + scanf("%*c%s",m->departement); + printf("\n\nEntrez le nombre de places disponibles dans le département : "); scanf("%d",&m->nbp); - printf("\n\nEntrez le nom du responsable de département :"); - char resp[51]; - scanf("%*c%s",&resp); - strcpy(m->resp,resp); - printf("\n\nLe département %s a bien été ajouté à l'IUT de %s.\n",dep,ville); + printf("\n\nEntrez le nom du responsable de département : \n"); + scanf("%*c"); + fgets(m->resp, 51, stdin); + printf("\n\nLe département %s a bien été ajouté à l'IUT de %s.\n",m->departement,ville); return; } void supprimerDep(VilleIUT* tiut[],int tlogi){ - printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):"); + printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner): "); char ville[31]; - scanf("%*c%s",&ville); + scanf("%s",ville); if(ville[0]=='Q' && ville[1]=='\0') return; - int noVille=rechercheTabPtVilleIUT(tiut,tlogi,ville); - if(noVille<=0){ + int noVille=rechercheIUT(tiut,tlogi,ville); + if(noVille<0){ fprintf(stderr,"\nVille non existante !\n"); return; } VilleIUT* v=tiut[noVille]; printf("\n\nEntrez le département à supprimer:"); char dep[31]; - scanf("%*c%s",&dep); - if(!existeDep(tiut->ldept,dep)){ + scanf("%s",dep); + if(!existeDep(v->ldept,dep)){ fprintf(stderr,"\nDépartement non existant !\n"); return; } @@ -236,6 +284,7 @@ void supprimerDep(VilleIUT* tiut[],int tlogi){ if(m->departement==dep){ printf("\n\nVoulez-vous supprimer le département %s de la ville de %s ? (Y pour continuer)\n\n",m->departement,v->Ville); char choix; + scanf("%*c%c",&choix); if(choix!='Y') return; v->ldept=m->suivant; free(m); @@ -244,6 +293,7 @@ void supprimerDep(VilleIUT* tiut[],int tlogi){ while(m->suivant->departement!=dep) m=m->suivant; printf("\n\nVoulez-vous supprimer le département %s de la ville de %s ? (Y pour continuer)\n\n",m->suivant->departement,v->Ville); char choix; + scanf("%*c%c",&choix); if(choix!='Y') return; MaillonDep* temp; temp=m->suivant; @@ -255,20 +305,20 @@ void supprimerDep(VilleIUT* tiut[],int tlogi){ } void modifNomResponsable(VilleIUT* tiut[],int tlogi){ - printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):"); + printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner): "); char ville[31]; - scanf("%*c%s",&ville); + scanf("%s",ville); if(ville[0]=='Q' && ville[1]=='\0') return; - int noVille=rechercheTabPtVilleIUT(tiut,tlogi,ville); - if(noVille<=0){ + int noVille=rechercheIUT(tiut,tlogi,ville); + if(noVille<0){ fprintf(stderr,"\nVille non existante !\n"); return; } VilleIUT* v=tiut[noVille]; printf("\n\nEntrez le département à modifier:"); char dep[31]; - scanf("%*c%s",&dep); - if(!existeDep(tiut->ldept,dep)){ + scanf("%s",dep); + if(!existeDep(v->ldept,dep)){ fprintf(stderr,"\nDépartement non existant !\n"); return; } @@ -276,8 +326,31 @@ void modifNomResponsable(VilleIUT* tiut[],int tlogi){ while(m->departement!=dep) m=m->suivant; printf("\n\nLe responsable du département %s de l'IUT de la ville de %s est actuellement %s. Quel est le nom du nouveau responsable ?\n\n",m->departement,v->Ville,m->resp); char nom[51]; - scanf("%d",&nom); + scanf("%s",nom); strcpy(m->resp,nom); printf("\n\nLe nom du responsable du département %s de l'IUT de %s a bien été changé pour %s.\n",dep,ville,nom); return; -} \ No newline at end of file +} + +void creerIUT(VilleIUT* tiut[],int* tlogi){ + printf("\nEntrez le nom de la ville correspondant à l'IUT à ajouter (Q pour abandonner): "); + char ville[31]; + scanf("%*c%s",ville); + if(ville[0]=='Q' && ville[1]=='\0') return; + int noVille=rechercheIUT(tiut,*tlogi,ville); + if(noVille>=0){ + fprintf(stderr,"\nVille déjà existante !\n"); + return; + } + VilleIUT* v=(VilleIUT*)malloc(sizeof(VilleIUT)); + if(v==NULL){ + perror("malloc"); + exit(errno); + } + strcpy(v->Ville,ville); + v->ldept=NULL; + tiut[*tlogi]=v; + *tlogi=*tlogi+1; + printf("\n\nL'IUT de %s a bien été ajouté.\n",ville); + return; +} diff --git a/src/partie1/saeP1.h b/src/partie1/saeP1.h index d52d2d6..84f282c 100644 --- a/src/partie1/saeP1.h +++ b/src/partie1/saeP1.h @@ -28,7 +28,7 @@ void SearchIUTFromDep(VilleIUT* lvIUT[],int tlogi); //Admin -void menuAdmin(VilleIUT* tiut[],int tlogi); +void menuAdmin(VilleIUT* tiut[],int* tlogi); void modifPlaces(VilleIUT* tiut[],int tlogi); @@ -36,4 +36,6 @@ void creerDep(VilleIUT* tiut[],int tlogi); void supprimerDep(VilleIUT* tiut[],int tlogi); -void modifNomResponsable(VilleIUT* tiut[],int tlogi); \ No newline at end of file +void modifNomResponsable(VilleIUT* tiut[],int tlogi); + +void creerIUT(VilleIUT* tiut[],int* tlogi); diff --git a/src/partie2/Makefile b/src/partie2/Makefile index 7ded601..f0f54bb 100644 --- a/src/partie2/Makefile +++ b/src/partie2/Makefile @@ -7,4 +7,4 @@ doc : saeP2.h doxygen clean : - rm -f saeP2.o \ No newline at end of file + rm -f saeP2.o diff --git a/src/partie2/saeP2.c b/src/partie2/saeP2.c index 1cfa471..0e29e1e 100644 --- a/src/partie2/saeP2.c +++ b/src/partie2/saeP2.c @@ -2,13 +2,15 @@ #include #include #include "saeP2.h" - +#include +#include "../annexe/saeAnnexe.h" +#include "../partie1/saeP1.h" candidat* LoadCandid(void) { //J'ouvre le fichier FILE* file; - if((file=fopen(candid.bin,"wb")==NULL) + if((file=fopen("candid.bin","rb"))==NULL) { perror("Erreur : "); exit(1); @@ -16,98 +18,173 @@ candidat* LoadCandid(void) //Lire la première ligne pr savoir combien d'étudiant je vais lire int nbcandid; fread(&nbcandid,sizeof(int),1,file); - candidat Listecandidat[nbcandid]; + candidat* Tabcandidat=(candidat*) malloc (sizeof(candidat)*nbcandid); //Tant que j'ai des étudiants à lire : for(int i=0;nbcandid>i;++i) { -//Son numéro, Son nom, Son prenom, liste de note - int numcandid; - char surname[31]; - char name[31]; - float note[4]; - fread(&numcandid,sizeof(int),1,file); - fread(surname,sizeof(char)*31,1,file); - fread(name,sizeof(char)*31,1,file); - fread(note,sizeof(int)*4,1,file); +//Son numéro, Son nom, Son prenom, liste de note` + candidat Candidat_ajout; + fread(&Candidat_ajout.numcandid,sizeof(int),1,file); + fread(Candidat_ajout.surname,sizeof(char)*31,1,file); + fread(Candidat_ajout.name,sizeof(char)*31,1,file); + fread(Candidat_ajout.note,sizeof(float)*4,1,file); //Son nb de choix - int nbchoix; - fread(&nbchoix,sizeof(int),1,file); + fread(&Candidat_ajout.nbchoix,sizeof(int),1,file); //Tant que j'ai pas fait tout ces choix : - for(int y=0;yville,sizeof(char)*31,1,file); + fread(voeu_ajout->dep,sizeof(char)*31,1,file); + fread(&voeu_ajout->ddep,sizeof(int),1,file); + fread(&voeu_ajout->vcand,sizeof(int),1,file); + Candidat_ajout.TabVoeu[i]=voeu_ajout; } - Candidat_ajout.numcandid=numcandid; - Candidat_ajout.surname=surname; - Candidat_ajout.name=name; - Candidat_ajout.note=note; - Candidat_ajout.ListeVoeu=ListeVoeu_ajout; - Listecandidat[i]=Candidat_ajout; + Tabcandidat[i]=Candidat_ajout; } //Je sors en disant que le load est sucessful - printf("Chargement réussie.") - return Listecandidat; + printf("Chargement réussie."); + return Tabcandidat; +} + +void SaveCandid(int nbcandidat,candidat *tcandidat) +{ +//J'ouvre le fichier + FILE* file; + if((file=fopen("candid.bin","wb"))==NULL) + { + perror("Erreur : "); + exit(1); + } +//J'écris le nombre d'étudiant que je rentres + fwrite(&nbcandidat,sizeof(int),1,file); +//J'écris tout mes étudiants + fwrite(tcandidat,sizeof(candidat),nbcandidat,file); + printf("Sauvegarde réussit"); } -void RechercheCandidat(int ID, int nbcandidat, int tmax,candidat *tcand) + +void RechercheCandidat(int ID, int nbcandidat,candidat *tcandidat) { for(int i=0;iville,tcandidat[i].TabVoeu[y]->dep); + if(tcandidat[i].TabVoeu[y]->ddep==0) printf("Dossier non traité\n"); + else + { + if(tcandidat[i].TabVoeu[y]->ddep==1) printf("Admis\n"); + else + { + if (tcandidat[i].TabVoeu[y]->ddep==2) printf("Liste d'attente\n"); else printf("Refusé\n"); } } - printf("Décision du candidat : ") - if(==0) printf("Décision non rendu\n"); - else { - if(==1) printf("Accepté\n"); - else prinf("Refusé"); + printf("Décision du candidat : "); + if(tcandidat[i].TabVoeu[y]->vcand==0) printf("Décision non rendu\n"); + else + { + if(tcandidat[i].TabVoeu[y]->vcand==1) printf("Accepté\n"); + else printf("Refusé"); } } return; } } printf("Candidat non trouvé"); - return; } +void ListeCandidat(int nbcandidat,candidat *tcandidat) +{ + for(int i=0;iville,tcandidat[i].TabVoeu[y]->dep); + if(tcandidat[i].TabVoeu[y]->ddep==0) printf("Dossier non traité\n"); + else + { + if(tcandidat[i].TabVoeu[y]->ddep==1) printf("Admis\n"); + else + { + if (tcandidat[i].TabVoeu[y]->ddep==2) printf("Liste d'attente\n"); + else printf("Refusé\n"); + } + } + printf("Décision du candidat : "); + if(tcandidat[i].TabVoeu[y]->vcand==0) printf("Décision non rendu\n"); + else + { + if(tcandidat[i].TabVoeu[y]->vcand==1) printf("Accepté\n"); + else printf("Refusé"); + } + } + return; + } + + printf("Candidat non trouvé"); +} + +void Candidater(VilleIUT* tiut[],int *tlogi, candidat* tcandidat, int numcandid) +{ + char VilleRech[31]; + printf("Veuillez entrez la ville de l'IUT au quel vous souhaitez candidatez :"); + scanf("%s",VilleRech); + int ind=rechercheIUT(tiut,*tlogi,VilleRech); + if(ind==-1) return; + else + { + char DepRech[31]; + printf("Veuillez entrez le département dans lequel vous souhaitez y postuler :"); + scanf("%s",DepRech); + if (existeDep(tiut[ind]->ldept, DepRech)==0) return; + else + { + int i; + for (i=0;tcandidat[i].numcandid!=numcandid;++i); + voeu* voeu_ajout = (voeu*) malloc (sizeof(voeu)); + strcpy(voeu_ajout->ville,VilleRech); + strcpy(voeu_ajout->dep,DepRech); + voeu_ajout->ddep=0; + voeu_ajout->vcand=0; + tcandidat[i].TabVoeu[tcandidat[i].nbchoix]=voeu_ajout; + tcandidat[i].nbchoix++; + } + + } +} + + //void gestionPhaseCandidatures(); A FAIRE. \ No newline at end of file diff --git a/src/partie2/saeP2.h b/src/partie2/saeP2.h index 2cbcd60..0a22b0a 100644 --- a/src/partie2/saeP2.h +++ b/src/partie2/saeP2.h @@ -1,3 +1,4 @@ + typedef struct { char ville[31]; @@ -11,10 +12,14 @@ typedef struct int numcandid; char surname[31]; char name[31]; - int note[4]; - voeu ListeVoeu[100]; + float note[4]; + int nbchoix; + voeu* TabVoeu[20]; }candidat; candidat* LoadCandid(void); - -//void gestionPhaseCandidatures(); A FAIRE. \ No newline at end of file +void SaveCandid(int nbcandidat,candidat *tcandidat); +void RechercheCandidat(int ID, int nbcandidat,candidat* tcandidat); +void ListeCandidat(int nbcandidat,candidat *tcandidat); +void Candidater(VilleIUT* tiut[],int *tlogi, candidat* tcandidat,int numcandid); +//void gestionPhaseCandidatures(); A FAIRE. diff --git a/src/saeMain.c b/src/saeMain.c index c600770..24469ce 100644 --- a/src/saeMain.c +++ b/src/saeMain.c @@ -9,6 +9,7 @@ int main(void) { + system("clear"); VilleIUT* tiut[36529]; int tlogi=loadIUT(tiut); menu(); @@ -28,8 +29,14 @@ int main(void) case 'S': saveIUT(tiut,tlogi); reset(); + break; + case 'Q': + printf("Êtes-vous sûr de vouloir quitter ? (Y pour continuer)\n\n"); + scanf("%*c%c",&confirmation); + if(confirmation=='Y') quit=1; + system("clear"); } saveIUT(tiut,tlogi); printf("L'application se ferme ..."); return 0; -} \ No newline at end of file +}