A menção Tn.q indica a questão q do teste nº n.
with Ada.Text_IO; procedure Olá_Mundo is begin Ada.Text_IO.Put_Line ("Olá, Mundo!"); end;
package Ariane_X is type Parte is tagged record Estado_Operacional_OK : Boolean := True; end record; function OK (X : Parte) return Boolean; type Reactor is new Parte with null record; procedure Acender (X : Reactor); procedure Apagar (X : Reactor); type Reactor_Principal is new Reactor with null record; type Reactor_Auxiliar is new Reactor with null record; procedure Descartar (X : Reactor_Auxiliar); type Navegador_Orbital is new Parte with null record; subtype Orbita is String; procedure Ir (Nav : Navegador_Orbital; Orb : Orbita); type Item_De_Carga is new Parte with null record; procedure Desembarcar (X : Item_De_Carga); RP : aliased Reactor_Principal; RA1 : aliased Reactor_Auxiliar; RA2 : aliased Reactor_Auxiliar; NA : aliased Navegador_Orbital; type Parte_Access is access all Parte'Class; Nave : array (Positive range <>) of Parte_Access := (RP'Access, RA1'Access, RA2'Access, NA'Access); type Itens_De_Carga is array (Positive range <>) of Item_De_Carga; function All_Systems_Go (Carga : Itens_De_Carga) return Boolean; procedure Acender_Todos_Reactores; procedure Apagar_E_Descartar_Reactores_Auxiliares; procedure Regressar; end; package body Ariane_X is function OK (X : Parte) return Boolean is begin return X.Estado_Operacional_OK; end; procedure Acender (X : Reactor) is begin null; end; procedure Apagar (X : Reactor) is begin null; end; procedure Descartar (X : Reactor_Auxiliar) is begin null; end; procedure Ir (Nav : Navegador_Orbital; Orb : Orbita) is begin null; end; procedure Desembarcar (X : Item_De_Carga) is begin null; end; function All_Systems_Go (Carga : Itens_De_Carga) return Boolean is begin for I in Nave'Range loop if not OK (Nave (I).all) then return False; end if; end loop; for I in Carga'Range loop if not OK (Carga (I)) then return False; end if; end loop; return True; end; procedure Acender_Todos_Reactores is begin for I in Nave'Range loop if Nave (I).all in Reactor'Class then Acender (Reactor (Nave (I).all)); end if; end loop; end; procedure Apagar_E_Descartar_Reactores_Auxiliares is begin for I in Nave'Range loop if Nave (I).all in Reactor_Auxiliar'Class then Apagar (Reactor_Auxiliar (Nave (I).all)); Descartar (Reactor_Auxiliar (Nave (I).all)); end if; end loop; end; procedure Regressar is begin null; end; end;
with Ariane_X; use Ariane_X; procedure Missao is SatCom1, SatCom2, SatMet1, SatMet2 : Item_De_Carga; Carga : Itens_De_Carga := (SatCom1, SatCom2, SatMet1, SatMet2); type Orbitas is (GE1, GE2, CP1, CP2); Destino : array (Carga'Range) of Orbitas := (GE1, GE2, CP1, CP2); begin if All_Systems_Go (Carga) then Acender_Todos_Reactores; delay 30.0; Apagar_E_Descartar_Reactores_Auxiliares; delay 60.0; Apagar (RP); for I in Carga'Range loop Ir (NA, Orbitas'Image (Destino (I))); end loop; Regressar; end if; end;
Transcript show: 'Olá, mundo!'