diff --git a/src/partie1/saeP1.c b/src/partie1/saeP1.c index 78f00af..0545ea5 100644 --- a/src/partie1/saeP1.c +++ b/src/partie1/saeP1.c @@ -155,19 +155,15 @@ void modifPlaces(VilleIUT* tiut{},int tlogi){ return; } VilleIUT* v=tiut[noVille]; - printf("\n\nEntrez le département à modifier (Q pour abandonner):"); + printf("\n\nEntrez le département à modifier:"); char dep[31]; scanf("%*c%s",&dep); - if(dep=="Q") return; if(!existe(tiut->ldept,dep)){ fprintf(stderr,"\nDépartement non existant !\n"); return; } MaillonDep* m=v->ldept - int r=recherche(v->ldept,dep); - for(int i=0; isuivant; - } + while(m->departement!=dep) m=m->suivant; printf("\n\nIl y a actuellement %d place(s) dans le département. A combien voulez-vous modifier ce nombre ?\n\n",m->nbp); int nPlaces; scanf("%d",&nPlaces); @@ -207,4 +203,43 @@ void creerDep(VilleIUT* tiut{},int tlogi){ m->resp=resp; printf("\n\nLe département %s a bien été ajouté à l'IUT de %s.\n",dep,ville); return; +} + +void supprimerDep(VilleIUT* tiut{},int tlogi){ + printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):"); + char* ville[31]; + scanf("%*c%s",&ville); + if(ville=="Q") return; + int noVille=rechercheTabPtVilleIUT(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(!existe(tiut->ldept,dep)){ + fprintf(stderr,"\nDépartement non existant !\n"); + return; + } + MaillonDep* m=v->ldept; + 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; + if(choix!="Y") return; + v->ldept=m->suivant; + free(m); + } + else{ + 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->suiv->departement,v->Ville); + char choix; + if(choix!="Y") return; + Maillon* temp=m->suivant; + m->suivant=m->suivant->suivant; + free(temp); + } + printf("\n\nLe département %s de l'IUT de %s a bien été supprimé.\n",dep,ville); + return; } \ No newline at end of file diff --git a/src/partie1/saeP1.h b/src/partie1/saeP1.h index 08724be..0bc96db 100644 --- a/src/partie1/saeP1.h +++ b/src/partie1/saeP1.h @@ -34,7 +34,7 @@ void modifPlaces(VilleIUT* tiut[],int tlogi); void creerDep(VilleIUT* tiut{},int tlogi); -//void supprimerDep(); +void supprimerDep(VilleIUT* tiut{},int tlogi); //void gestionPhaseCandidatures();