Advertisement
katarinaknobel

Föreläsning den 28/9

Sep 28th, 2017
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 1.43 KB | None | 0 0
  1. * Paket
  2. * Specifikationsdel (.ads)
  3. * Implementationsdel (.adb)
  4. * Publikt/privat
  5. * (Deklarera) undantag
  6. ----------------------------------
  7. with Time_Handling; use Time_Handling;
  8.  
  9. procedure Orientering is
  10. T1, T2 : Time_Type;
  11.  
  12. begin
  13. Get(T1);
  14. Get(T2);
  15. Put(T1);
  16.  
  17.  
  18.  
  19. end Orientering;
  20.  
  21. -------------------------------------
  22. (Specifikationsdelen)
  23. allt som är över private --> Publik del
  24. allt som är under private --> Privat del
  25. specifikationsdelen innehåller bara information om vad som finns
  26.  
  27. with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
  28. with Ada.Text_IO; use Ada.Text_IO;
  29.  
  30. time_handling.ads
  31.  
  32. package Time_Handling is
  33.       type Time_Type is private -- berättar att datatypen finns, inte hur den fungerar
  34.       procedure Get(Item : out Time_Type);
  35.       procedure Put(Item : in Time_Type);
  36.       function "<"(Left, Right: in Time_Type) return Boolean;
  37.  
  38. private
  39.     type Time_Type is
  40.        record
  41.          H, M, S : Integer;
  42.        end record;
  43.  
  44.  
  45. end Time_Handling;
  46.  
  47. --------------------------------------
  48. (Implementationsdel)
  49.  
  50. time_handling.adb
  51.  
  52. package body Time_Handling is
  53.    
  54.    procedure Get(Item : out Time_Type) is
  55.    C: Character;
  56.  
  57.    begin
  58.    Get(Item.H);
  59.    Get(C)
  60.    Get(Item.M);
  61.    Get(C);
  62.    Get (Item.S);
  63.  
  64. end Get;
  65.  
  66. procedure Put(Item : in Time_Type) is
  67.  
  68. begin
  69.  
  70. end Put;
  71.  
  72. function "<"(Left, Right : in Time_Type) return Boolean is
  73. begin
  74.  
  75. end "<";
  76.  
  77. end Time_Handling;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement