-- This is the generic implementation for a stack abstract data type. package body StackPkg is someint: integer := 25; function IsFull (S : Stack) return Boolean is begin return S.Top = size; end IsFull; function IsEmpty (S : Stack) return Boolean is begin return S.Top = 0; end IsEmpty; procedure Push (Item : integer; S : in out Stack) is begin if IsFull (S) then raise Stack_Full; else S.Top := S.Top + 1; S.Elements(S.Top) := Item; end if; end Push; procedure Pop (S : in out Stack) is begin if IsFull (S) then raise Stack_Full; else S.Top := S.Top - 1; end if; end Pop; function Top (S : in Stack) return integer is begin if IsEmpty (S) then raise Stack_Empty; else return S.elements(S.Top); end if; end Top; end StackPkg;