package body Stack is procedure Clear (Stack : in out Stack_Type) is begin Stack.Top := 0; end Clear; ---------------------------------------------------------------------------- function isEmpty (Stack : in Stack_Type) return Boolean is temp: Boolean := false; begin -- return Stack.Top = 0; if Stack.top = 0 then temp := true; end if; return temp; end isEmpty; ---------------------------------------------------------------------------- function isFull (Stack : in Stack_Type) return Boolean is begin return Stack.Top = Stack.Max_Size; end isFull; ---------------------------------------------------------------------------- procedure Push (Stack : in out Stack_Type; New_Element : in Element_Type) is begin if not isFull (Stack) then Stack.Top := Stack.Top + 1; Stack.Elements (Stack.Top) := New_Element; else raise OVERFLOW; end if; end Push; ---------------------------------------------------------------------------- procedure Pop (Stack : in out Stack_Type; Popped_Element : out Element_Type) is begin if not isEmpty (Stack) then Popped_Element := Stack.Elements (Stack.Top); Stack.Top := Stack.Top - 1; else raise UNDERFLOW; end if; end Pop; end Stack;