Когда я пытаюсь запустить программу, я получаю сообщение об ошибке "end Animals;" ожидается, где я заканчиваю функцию "Init". Я новичок в программировании и просто не могу понять, в чем проблема. Он пытается заставить меня изменить его на «Прикончить животных»; но тогда это завершит пакет и не запустит остальную часть.
package body Animals is
function Init(
Name : in String;
Legs : in Natural;
WeightInGrams : in Positive;
HeightInCm : in Positive)
return Creature;
TempCreature : Creature;
begin
TempCreature.Name := To_Unbounded_String(Name);
TempCreature.Legs := Legs;
TempCreature.WeightInGrams := WeightInGrams;
TempCreature.HeightInCm := HeightInCm;
return TempCreature;
end Init; ***--"end Animals;" expected***
function Init return Creature is
TempCreature : Creature;
begin
TempCreature.Name := To_Unbounded_String("Dog");
TempCreature.Legs := 4;
TempCreature.WeightInGrams := 3000;
TempCreature.HeightInCm := 40;
return TempCreature;
end Init;
procedure Set_Legs(
Creat : in out Creature;
Legs : in Natural) is
begin
Creat.Legs := Legs;
end Set_Legs;
procedure Set_Weight(
Creat : in out Creature;
WeightInGrams : in Positive) is
begin
Creat.WeightInGrams := WeightInGrams;
end Set_Weight;
procedure Set_Height(
Creat : in out Creature;
HeightInCm : in Positive) is
begin
Creat.HeightInCm := HeightInCm;
end Set_Height;
function Get_Legs(
Creat : in out Creature)
return Natural is
begin
return Creat.Legs;
end Get_Legs;
function Get_Weight(
Creat : in out Creature)
return Positive is
begin
return Creat.WeightInGrams;
end Get_Weight;
function Get_Height(
Creat : in out Creature)
return Positive is
begin
return Creat.HeightInCm;
end Get_Height;
overriding procedure Finalize(
Creat : in out Creature) is
begin
Put_Line("Resetting values of Creat to defaults.");
Creat.Name := Null_Unbounded_String;
Creat.Legs := 0;
Creat.WeightInGrams := 1;
Creat.HeightIncm := 1;
end Finalize;
procedure Print_Record(Creat : in out Creature) is
begin
Private_Print_Record(Creat);
end Print_Record;
procedure Private_Print_Record(Creat : in out Creature) is
begin
Put_Line("The animal: ");
Put_Line("The name: " & To_String(Creat.Name));
Put_Line("Number of legs: " & Natural'Image(Creat'Legs));
Put_Line("Weight in grams: " & Positive'Image(Creat.WeightInGrams));
Put_Line("Height in cm: " & Positive'image(Creat.HeightInCm));
end Private_Print_Record;
end Animals;