diff --git a/part1.c b/part1.c index 37edde7..2e5c610 100644 --- a/part1.c +++ b/part1.c @@ -106,7 +106,7 @@ int Chargement(VilleIUT **tV, int tmax, char *nameFile) void AfficheDpmt ( MaillonDept *dpt )//Affiche un département d'une liste { if ( dpt == NULL) return; - printf("%s %d %s \n", dpt->departement, dpt->nbP, dpt->respAd); + printf("%s \t%d \t%s \n", dpt->departement, dpt->nbP, dpt->respAd); AfficheDpmt(dpt->suiv); } @@ -114,7 +114,7 @@ void AfficheDpmt ( MaillonDept *dpt )//Affiche un département d'une liste void afficheIUT (VilleIUT *iut)//Affiche un iut avec ses départements { - printf ("%s \n", iut->ville); + printf ("%s \t\n", iut->ville); AfficheDpmt(iut->ldept); } @@ -124,10 +124,30 @@ void Affichetableau(VilleIUT ** TabIUT, int n )//Affiche le tableau des iuts ave { int i; for ( i = 0 ; i < n ; i++ ) - afficheIUT(TabIUT[i]); + if ( TabIUT[i]->nbDept > 0) + afficheIUT(TabIUT[i]); } +void AffnbPdpt ( MaillonDept *dpt )//Affiche nombre de place par département d'une liste +{ + if ( dpt == NULL) return; + printf("%s \t%d \n", dpt->departement, dpt->nbP); + AfficheDpmt(dpt->suiv); +} +void affichenbPIUT (VilleIUT *iut)//Affiche nombre de place restante d'un iut avec ses départements +{ + printf ("%s \n", iut->ville); + AffnbPdpt(iut->ldept); +} + +void AffichenbPtableau(VilleIUT ** TabIUT, int n )//Affiche le tableau de places restantes des iuts avec leurs départements +{ + int i; + for ( i = 0 ; i < n ; i++ ) + if ( TabIUT[i]->nbDept > 0) + affichenbPIUT(TabIUT[i]); +} @@ -373,12 +393,13 @@ int Admin(VilleIUT **tV, int nb) int reponse; printf("*****************************************************\n"); - printf("*---------------------Accueil-----------------------*\n"); + printf("*------------------Adminitrateur--------------------*\n"); printf("*-----1-modifier nombre places d'un département-----*\n"); printf("*--------2-créer un département dans un IUT---------*\n"); printf("*------3-supprimer un département dans un IUT-------*\n"); printf("*-----4-modifier le nom du chef de département------*\n"); printf("*---------5-arrêter la phase de candidatures--------*\n"); + //printf("*--------------------6-Retour-----------------------*\n"); printf("*****************************************************\n"); scanf("%d", &reponse); printf("%d", reponse); @@ -389,5 +410,99 @@ int Admin(VilleIUT **tV, int nb) case 3: deleteIUT(tV, nb); return 0; case 4: MaJnameC(tV, nb); return 0; case 5: Save(tV, nb); return 1; + //case 6: exit(1); + } } + + + + + + +int utilisateur (VilleIUT **tV, int nb){//Onglet accueille des utilisateurs + +int reponse, i; +char rdpt[20]; +MaillonDept * ldepart; + + printf("*****************************************************\n"); + printf("*-------------------Utilisateur---------------------*\n"); + printf("*------1-Affichage de toutes les informations-------*\n"); + printf("*-----2-Places restantes pour la première année-----*\n"); + printf("*----------3-Recherche d'un departement-------------*\n"); + printf("*--------------------4-Retour-----------------------*\n"); + printf("*****************************************************\n"); + + scanf("%d", &reponse); + printf("%d", reponse); + while ( reponse == 1 || reponse == 2 || reponse == 3 || reponse == 4){ + if ( reponse == 1 ){ + Affichetableau(tV, nb); + return 0; + } + if ( reponse == 2){ + AffichenbPtableau(tV, nb); + return 0; + } + if ( reponse == 3){ + printf("Quel departement souhaitez vous integrer?\n"); + scanf("%s", rdpt); + for ( i = 0 ; i < nb ; i++){ + ldepart = recherche (tV[i]->ldept, rdpt); + AfficheDpmt(ldepart); + } + return 0; + } + if ( reponse == 4 ) + return 2; + } + return 0 ; +} + + +void test (void){ // fonction globale + + int acc, nb, nbville, repAdm, repVis; + VilleIUT *tV[200]; + + nbville = Chargement(tV, 200, "part1.don"); + + printf("*****************************************************\n"); + printf("*---------------------Accueil-----------------------*\n"); + printf("*-----------------1-Adminitrateur-------------------*\n"); + printf("*-------------------2-Visiteur----------------------*\n"); + printf("*-------------------3-Quitter-----------------------*\n"); + printf("*****************************************************\n"); + scanf("%d", &acc); + + while ( acc == 1 || acc == 2){ + + if (acc == 1){ + repAdm = Admin (tV, nbville); + } + if (acc == 2){ + repVis = utilisateur (tV, nbville); + + if (repVis == 2){ + acc = 3; + } + } + if ( acc == 3 ){ + Save( tV, nb ); + exit; + } + return; + } +} + + + +/* SOUCIS AVEC LA FONCTION TEST, JE N'ARRIVE PAS A SORTIR DU WHILE POUR RETOURNER AU MENU PRINCIPAL +ADMIN/ VISITEUR. FONCTION RECURCIVE? + +FONCTION RECHERCHE DANS TEST NE RETURN RIEN +FONCTION AFFICHAGE nbP AFFICHE QUAND MEME LE NOM DES RESPONSABLE... MAIS PAS TOUS +JE PEUX Y REVENIR DEMAIN SUR MA PARTIE, PAR CONTRE SUR TA PARTIE JE CROIS QU'IL Y A DES ERREURS +DE SEGMENTATION HESITE PAS A FAIRE RE RUN LE TRUC +*/ \ No newline at end of file diff --git a/part1.don b/part1.don index 45776df..9c7fe10 100644 --- a/part1.don +++ b/part1.don @@ -1,12 +1,18 @@ Grenoble 3 -Informatique 112 Dupont Jean -Bio-Informatique 116 Dupont Virginie -Biologie 124 Dupont Marie +Informatique---- 112 Dupont Jean +Bio-Informatique 116 Dupont Virginie +Biologie-------- 124 Dupont Marie Clermont-Ferrand 2 -Informatique 136 Simon Carine -Biologie 154 Jean Claude +Informatique---- 136 Simon Carine +Biologie-------- 154 Jean Claude Aurillac 2 -Biologie 102 Michèle Robert -Bio-Informatique 98 Claude Loeb +Biologie-------- 102 Michèle Robert +Bio-Informatique 98 Claude Loeb + +Limoges 0 + +Annecy 1 +Informatique---- 120 Duvillard André + diff --git a/part1.h b/part1.h index 57d2087..8f553ec 100644 --- a/part1.h +++ b/part1.h @@ -39,3 +39,8 @@ void MaJnameC(VilleIUT **tV, int nb);//mise à jour du nom du chef de départeme void Save(VilleIUT **tV, int nb);//sauvegarde le fichier void SaveEltList(FILE *fs, ListDept l);//sauvegarde un élément de liste int Admin(VilleIUT **tV, int nb);//partie admin de la première partie +void AffnbPdpt ( MaillonDept *dpt );//Affiche nombre de place par département d'une liste +void affichenbPIUT (VilleIUT *iut);//Affiche nombre de place restante d'un iut avec ses départements +void AffichenbPtableau(VilleIUT ** TabIUT, int n );//Affiche le tableau de places restantes des iuts avec leurs départements +int utilisateur (VilleIUT **tV, int nb);//Onglet accueille des utilisateurs +void test (void); // fonction globale diff --git a/tpart1.c b/tpart1.c index d0aa064..e8b8abd 100644 --- a/tpart1.c +++ b/tpart1.c @@ -12,11 +12,6 @@ int main(void) int nb, reponse; VilleIUT *v; ListDept l; - nb = Chargement(tV, 200, "part1.don"); - reponse = Admin(tV, nb); - printf("%d\n", reponse); - printf("\n\n\n"); - Affichetableau(tV, nb); - + test (); return 0; }