-- Chapter 23 - Program 11 with Ada.Text_IO, Ada.Integer_Text_IO; use Ada.Text_IO, Ada.Integer_Text_IO; package Person.Positions is -- The SUPERVISOR type has a title. type SUPERVISOR is new EMPLOYEE with private; procedure Init_Data(In_Person : in out SUPERVISOR; In_Name : BOUNDED_STRING; In_Salary : INTEGER; In_Title : BOUNDED_STRING); procedure Display(In_Person : SUPERVISOR); -- The PROGRAMMER type has a language preference. type PROGRAMMER is new EMPLOYEE with private; procedure Init_Data(In_Person : in out PROGRAMMER; In_Name : BOUNDED_STRING; In_Salary : INTEGER; In_Title : BOUNDED_STRING; In_Language : BOUNDED_STRING); procedure Display(In_Person : PROGRAMMER); -- The SECRETARY type has a typing speed. type SECRETARY is new EMPLOYEE with private; procedure Init_Data(In_Person : in out SECRETARY; In_Name : BOUNDED_STRING; In_Salary : INTEGER; In_ShortHand : BOOLEAN; In_Speed : INTEGER); procedure Display(In_Person : SECRETARY); private type SUPERVISOR is new EMPLOYEE with record Title : BOUNDED_STRING; end record; type PROGRAMMER is new EMPLOYEE with record Title : BOUNDED_STRING; Language : BOUNDED_STRING; end record; type SECRETARY is new EMPLOYEE with record Shorthand : BOOLEAN; Typing_Speed : INTEGER; end record; end Person.Positions; package body Person.Positions is -- Subprograms for the SUPERVISOR type. procedure Init_Data(In_Person : in out SUPERVISOR; In_Name : BOUNDED_STRING; In_Salary : INTEGER; In_Title : BOUNDED_STRING) is begin In_Person.Name := In_Name; In_Person.Salary := In_Salary; In_Person.Title := In_Title; end Init_Data; procedure Display(In_Person : SUPERVISOR) is begin for Index in 1..Length(In_Person.Name) loop Put(Element(In_Person.Name, Index)); end loop; Put(" is a supervisor, and is the "); for Index in 1..Length(In_Person.Title) loop Put(Element(In_Person.Title, Index)); end loop; Put(" of the company"); New_Line; end Display; -- Subprograms for the PROGRAMMER type. procedure Init_Data(In_Person : in out PROGRAMMER; In_Name : BOUNDED_STRING; In_Salary : INTEGER; In_Title : BOUNDED_STRING; In_Language : BOUNDED_STRING) is begin In_Person.Name := In_Name; In_Person.Salary := In_Salary; In_Person.Title := In_Title; In_Person.Language := In_Language; end Init_Data; procedure Display(In_Person : PROGRAMMER) is begin for Index in 1..Length(In_Person.Name) loop Put(Element(In_Person.Name, Index)); end loop; Put(" is a programmer specializing in "); for Index in 1..Length(In_Person.Language) loop Put(Element(In_Person.Language, Index)); end loop; Put(". He makes "); Put(In_Person.Salary, 6); Put(" dollars per year."); New_Line; end Display; -- Subprograms for the SECRETARY type. procedure Init_Data(In_Person : in out SECRETARY; In_Name : BOUNDED_STRING; In_Salary : INTEGER; In_ShortHand : BOOLEAN; In_Speed : INTEGER) is begin In_Person.name := In_Name; In_Person.Salary := In_Salary; In_Person.Shorthand := In_Shorthand; In_Person.Typing_Speed := In_Speed; end Init_Data; procedure Display(In_Person : SECRETARY) is begin for Index in 1..Length(In_Person.Name) loop Put(Element(In_Person.Name, Index)); end loop; Put(" is a secretary that does "); if not In_Person.Shorthand then Put("not "); end if; Put("take shorthand."); New_Line; Put(" "); for Index in 1..Length(In_Person.Name) loop Put(Element(In_Person.Name, Index)); end loop; Put(" is paid "); Put(In_Person.Salary, 6); Put(" dollars per year."); New_Line; end Display; end Person.Positions; -- Result of execution -- -- (This package cannot be executed alone.)