-- Chapter 23 - Program 6 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 : STRING; In_Salary : INTEGER; In_Title : 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 : STRING; In_Salary : INTEGER; In_Title : STRING; In_Language : 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 : STRING; In_Salary : INTEGER; In_ShortHand : BOOLEAN; In_Speed : INTEGER); procedure Display(In_Person : SECRETARY); private type SUPERVISOR is new EMPLOYEE with record Title : STRING(1..25); Title_Length : INTEGER; end record; type PROGRAMMER is new EMPLOYEE with record Title : STRING(1..25); Title_Length : INTEGER; Language : STRING(1..25); Language_Length : INTEGER; 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 : STRING; In_Salary : INTEGER; In_Title : STRING) is begin In_Person.Name_Length := In_Name'Length; for Index in In_Name'Range loop In_Person.Name(Index) := In_Name(Index); end loop; In_Person.Salary := In_Salary; In_Person.Title_Length := In_Title'Length; for Index in In_Title'Range loop In_Person.Title(Index) := In_Title(Index); end loop; end Init_Data; procedure Display(In_Person : SUPERVISOR) is begin for Index in 1..In_Person.Name_Length loop Put(In_Person.Name(Index)); end loop; Put(" is a supervisor, and is the "); for Index in 1..In_Person.Title_Length loop Put(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 : STRING; In_Salary : INTEGER; In_Title : STRING; In_Language : STRING) is begin In_Person.Name_Length := In_Name'Length; for Index in In_Name'Range loop In_Person.Name(Index) := In_Name(Index); end loop; In_Person.Salary := In_Salary; In_Person.Title_Length := In_Title'Length; for Index in In_Title'Range loop In_Person.Title(Index) := In_Title(Index); end loop; In_Person.Language_Length := In_Language'Length; for Index in In_Language'Range loop In_Person.Language(Index) := In_Language(Index); end loop; end Init_Data; procedure Display(In_Person : PROGRAMMER) is begin for Index in 1..In_Person.Name_Length loop Put(In_Person.Name(Index)); end loop; Put(" is a programmer specializing in "); for Index in 1..In_Person.Language_Length loop Put(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 : STRING; In_Salary : INTEGER; In_ShortHand : BOOLEAN; In_Speed : INTEGER) is begin In_Person.Name_Length := In_Name'Length; for Index in In_Name'Range loop In_Person.Name(Index) := In_Name(Index); end loop; 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.. In_Person.Name_Length loop Put(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..In_Person.Name_Length loop Put(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.)