text
stringlengths 0
234
|
|---|
Correct := False;
|
while not Correct loop
|
Put_Line ("Entrez la clé de la personne a lier [0 pour retour].");
|
Choisir_Cle (Cle_Destination);
|
Correct :=
|
Cle_Destination = 0
|
or else Existe_Registre (Etat.Arbre, Cle_Destination);
|
if not Correct then
|
Put_Line ("Clé inconnue.");
|
New_Line;
|
end if;
|
end loop;
|
if Cle_Destination = 0 then
|
Put_Line ("Ajout annulé.");
|
else
|
Personne_Origine := Lire_Registre (Etat.Arbre, Etat.Cle);
|
Personne_Destination := Lire_Registre (Etat.Arbre, Cle_Destination);
|
begin
|
case Relation_Lue is
|
when 1 =>
|
-- On vérifie qu'un parent est plus vieux que son enfant
|
if D1_Inf_D2
|
(Personne_Origine.Date_De_Naissance,
|
Personne_Destination.Date_De_Naissance)
|
then
|
raise Dates_Incompatibles;
|
end if;
|
Ajouter_Relation
|
(Etat.Arbre, Etat.Cle, A_Pour_Parent, Cle_Destination);
|
when 2 =>
|
if D1_Inf_D2
|
(Personne_Destination.Date_De_Naissance,
|
Personne_Origine.Date_De_Naissance)
|
then
|
raise Dates_Incompatibles;
|
end if;
|
Ajouter_Relation
|
(Etat.Arbre, Etat.Cle, A_Pour_Enfant, Cle_Destination);
|
when 3 =>
|
Ajouter_Relation
|
(Etat.Arbre, Etat.Cle, A_Pour_Conjoint, Cle_Destination);
|
when others =>
|
null;
|
end case;
|
Put_Line ("Relation ajoutée.");
|
exception
|
when Dates_Incompatibles =>
|
Put_Line ("Un parent doit etre plus agé que son enfant.");
|
when Relation_Existante =>
|
Put_Line
|
("Une relation entre ces deux personnes existe déja.");
|
Function Definition: procedure Initialiser (Graphe : out T_Graphe) is
|
Function Body: begin
|
Graphe := null;
|
end Initialiser;
|
procedure Desallouer_Sommet is new Ada.Unchecked_Deallocation (T_Sommet,
|
T_Graphe);
|
procedure Desallouer_Arete is new Ada.Unchecked_Deallocation (T_Arete,
|
T_Liste_Adjacence);
|
procedure Detruire_Arete (Adjacence : in out T_Liste_Adjacence) is
|
begin
|
if Adjacence /= null then
|
Detruire_Arete (Adjacence.all.Suivante);
|
end if;
|
Desallouer_Arete (Adjacence);
|
end Detruire_Arete;
|
procedure Detruire (Graphe : in out T_Graphe) is
|
begin
|
if Graphe /= null then
|
-- Détruit proprement un sommet
|
Detruire_Arete (Graphe.all.Arete);
|
Detruire (Graphe.all.Suivant);
|
end if;
|
Desallouer_Sommet (Graphe);
|
end Detruire;
|
function Trouver_Pointeur_Sommet
|
(Graphe : T_Graphe; Etiquette : T_Etiquette_Sommet) return T_Graphe
|
is
|
begin
|
if Graphe = null then
|
raise Sommet_Non_Trouve;
|
elsif Graphe.all.Etiquette = Etiquette then
|
return Graphe;
|
else
|
return Trouver_Pointeur_Sommet (Graphe.all.Suivant, Etiquette);
|
end if;
|
end Trouver_Pointeur_Sommet;
|
procedure Ajouter_Sommet
|
(Graphe : in out T_Graphe; Etiquette : T_Etiquette_Sommet)
|
is
|
Nouveau_Graphe : T_Graphe;
|
begin
|
begin
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.