Advertisement
icebit

Ada_04052016

May 4th, 2016
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 3.39 KB | None | 0 0
  1. w ads widoczne w mainie;
  2. -- GARAZ REKORD--
  3. -----------------
  4. with Ada.Text_IO;
  5. use Ada.Text_IO;
  6. with Ada.Integer_Text_IO;
  7. use Ada.Integer_Text_IO;
  8. with Ada.Numerics.Elementary_Functions;
  9. use Ada.Numerics.Elementary_Functions;
  10. with Ada.Float_Text_IO;
  11. use Ada.Float_Text_IO;
  12. with zmiana;
  13. use zmiana;
  14.  
  15. procedure Main is
  16.  
  17.    a : Float;
  18.    b : Float;
  19.    c : Float;
  20.  
  21.    type Kolor is (red, green, blue);
  22.    type Samochod is record
  23.       karoserja: Kolor;
  24.       rejestracja: String(1..6);
  25.       rok_prod: Integer;
  26.    end record;
  27.    type G is array (Positive range <>) of Samochod;
  28.    
  29.    M_G : G(1..5);
  30.    
  31.    car1 : Samochod:= (red, "ZK1 xD", 1995);
  32.    car2 : Samochod:= (green, "ZK2lel", 1925);
  33. begin
  34.  
  35.    
  36.    M_G(1) := car1;
  37.    M_G(2) := car2;
  38.    
  39.    Put(M_G(1).rejestracja);
  40. end Main;
  41.  
  42. 0-0--0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0
  43. =================================================
  44.  
  45. = = = = = = = = = = = = = = = = = = = = = = = = =
  46. -------------------------------------------------
  47. -------------------------------------------------
  48. --              KLASA PUNKT         --
  49. -------------------------------------------------
  50. -------------------------------------------------
  51. 0-0--0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0
  52. =================================================
  53.  
  54. = = = = = = = = = = = = = = = = = = = = = = = = =
  55. PLIK ADS
  56.  
  57. package zmiana is
  58.     type point is tagged recond
  59.         X : Integer;
  60.         Y : Integer;
  61. end record;
  62.  
  63. function obliczPole(pkt: point) return Float;
  64. end zmiana;
  65.  
  66. PLIK ADB
  67.  
  68. package body zmiana is
  69.  
  70.    function obliczPole(pkt: point) return Float is
  71.    begin
  72.       return 0.0;
  73.    end obliczPole;
  74.    
  75. end zmiana;
  76. ---------------------------
  77. druga klasa: KOLO:
  78. ----------------------------
  79. -----------------------------
  80. PLIK ADS
  81.  
  82. package zmiana2 is
  83.    type kolo is new point with record
  84.       r: Float;
  85.    end record;
  86.    
  87.    function obliczPole(pkt: kolo) return Float;
  88. end zmiana2;
  89.  
  90.    
  91.  
  92. PLIK ADB
  93. package zmiana2 body is
  94.  
  95.    
  96.    function obliczPole(pkt: kolo) return Float
  97.    begin
  98.       return 3.14 * k.r**2;
  99.    end obliczPole;
  100. end zmiana2;
  101.  
  102. MAIN:
  103.    pkt: Point := (2,3);
  104.    kol : Kolo :=(2,3,4.5);
  105.    
  106. begin
  107.    obliczPole(pkt);
  108.    obliczPole(kol);
  109.  
  110. ----------------------------------------------
  111. ------------------------------------------------
  112. ------------------------------------------------
  113. ------- WĄTKI  - > TASKI ------------------------
  114. ------------------------------------------------
  115. ------------------------------------------------
  116.  
  117. with Ada.Text_IO;
  118. use Ada.Text_IO;
  119. with Ada.Integer_Text_IO;
  120. use Ada.Integer_Text_IO;
  121. with Ada.Numerics.Elementary_Functions;
  122. use Ada.Numerics.Elementary_Functions;
  123. with Ada.Float_Text_IO;
  124. use Ada.Float_Text_IO;
  125.  
  126.  
  127. procedure Main is
  128.    
  129.    D1 : Duration;
  130.    D2 : Duration;
  131.  
  132.  
  133.    
  134.    task zadanie1;
  135.    task body zadanie1 is
  136.    begin
  137.    D1 := Duration(0.5);
  138.       for i in 1..120 loop
  139.          Put("HEJ!");
  140.          New_Line;
  141.          delay D1;
  142.       end loop;
  143.    end zadanie1;
  144.    
  145.    task zadanie2;
  146.    task body zadanie2 is
  147.      
  148.    begin
  149.          D2 := Duration(0.75);
  150.       for i in 1..120 loop
  151.          Put("HO!");
  152.          New_Line;
  153.          delay D2;
  154.       end loop;
  155.    end zadanie2;
  156.    
  157.  
  158. begin
  159. null;
  160.  
  161. end Main;
  162. -------------------------------------------
  163. -
  164. -------------------------------------------
  165. -
  166. -
  167. ---------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement