package body Immatriculation is
procedure Insérer_Etudiant (Liste : in out T_Queue_Dynamique; Info : in T_Info) is
Ptr_Nouveau : T_Lien := new T_Element'(Info, null);
begin -- Insérer_Etudiant
if Liste.Tete = null then
Liste.Tete := Ptr_Nouveau;
else
Liste.Queue.Suivant := Ptr_Nouveau;
end if;
Liste.Queue := Ptr_Nouveau;
end Insérer_Etudiant;
procedure Effacer_Etudiant (Liste : in out T_Queue_Dynamique; Numero : in Positive) is
Ptr_Courant : T_Lien := Liste.Tete;
begin -- Effacer_Etudiant
-- Liste vide
if Liste.Tete = null then
Put("Liste Vide : Impossible d'effacer une entrée.");
end if;
--Différents cas du pointeur courant
if Ptr_Courant = Liste.Tete then -- Courant sur le premier element
Liste.Tete := Ptr_Courant.Suivant
Libérer(Ptr_Courant);
elsif Ptr_Courant = Liste.Queue then -- Courant sur le dernier element
Liste.Queue := Ptr_Precedent;
Ptr_Precedent := null;
Libérer(Ptr_Courant);
elsif Ptr_Courant.Information.Numero = Numero then -- Courant en milieu de chaine
Ptr_Precedent.Suivant := Ptr_Courant.Suivant;
Libérer(Ptr_Courant); --Restitution de la mémoire
else
Ptr_Courant := Ptr_Courant.Suivant;
end if;
--Dernier element supprimé
if Liste.Tete = null then
Liste.Queue := null;
end if;
end Effacer_Etudiant;
procedure Tout_Afficher (Liste : in T_Queue_Dynamique) is
-- Repère le premier élément de la liste
Ptr_Courant : T_Lien := Liste.Tete;
begin -- Tout_Afficher
while Ptr_Courant /= null loop
Put("N° : ");
Put(Ptr_Courant.Information.Numero, 0);
Put(", ");
Put(Ptr_Courant.Information.Etudiant);
Put(", Date : ");
if Ptr_Courant.Information.Date.Jour < 10 then
Put ('0');
end if;
Put(Ptr_Courant.Information.Date.Jour, 0);
Put(".");
if Ptr_Courant.Information.Date.Mois < 10 then
Put ('0');
end if;
Put(Ptr_Courant.Information.Date.Mois, 0);
Put(".");
Put(Ptr_Courant.Information.Date.Année, 0);
Put(" ");
if Ptr_Courant.Information.Date.Heure < 10 then
Put ('0');
end if;
Put(Ptr_Courant.Information.Date.Heure, 0);
Put(":");
if Ptr_Courant.Information.Date.Minute < 10 then
Put ('0');
end if;
Put(Ptr_Courant.Information.Date.Minute, 0);
Put(":");
if Ptr_Courant.Information.Date.Seconde < 10 then
Put ('0');
end if;
Put(Ptr_Courant.Information.Date.Seconde, 0);
New_Line;
Ptr_Courant := Ptr_Courant.Suivant;
end loop;
end Tout_Afficher;
end Immatriculation;