Advertisement
Guest User

magazyn adb

a guest
Oct 18th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 1.07 KB | None | 0 0
  1. with GNAT.IO; use GNAT.IO;
  2. with Piwa;
  3.  
  4. package body Magazyn is
  5.  
  6.    function pobierz return Piwa.Piwo is
  7.    begin
  8.       if iloscSztuk > 0 then
  9.          put_line(">> MAGAZYN: wyjmuje piwo(" & Integer'Image(iloscSztuk) & "/" & Integer'Image(pojemnosc) & ")");
  10.          iloscSztuk := iloscSztuk - 1;
  11.       else
  12.          raise wyjatekMagazynu with "Magazyn jest pusty!";
  13.       end if;
  14.  
  15.       return kontener(iloscSztuk + 1);
  16.    end pobierz;
  17.  
  18.    procedure dodaj(piwko : in Piwa.Piwo) is
  19.    begin
  20.       if iloscSztuk < pojemnosc then
  21.          put(">> MAGAZYN: dodaje piwo(" & Integer'Image(iloscSztuk + 1) & "/" & Integer'Image(pojemnosc) & "): ");
  22.          put(Piwa.gatunki'Image(piwko.gatunek) & "" & Piwa.zawartoscAlkoholu'Image(piwko.moc) & "%");
  23.          new_line(1);
  24.       else
  25.          raise wyjatekMagazynu with "Magazyn jest pelen!";
  26.       end if;
  27.  
  28.       iloscSztuk := iloscSztuk + 1;
  29.       kontener(iloscSztuk) := piwko;
  30.    end dodaj;
  31.  
  32.    function sprawdzIloscSztuk return integer is
  33.    begin
  34.       return iloscSztuk;
  35.    end sprawdzIloscSztuk;
  36.  
  37. end Magazyn;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement