-- Assignment : Homework due Sept. 21st, 2006 -- Programmer : Daniel Koestler -- Course : CS 240 -- Date : Sept. 20th, 2006 -- Compiler : gcc with gnat -- Professor : Elizabeth Adams -- Filename : stack.ads -- Executable : -- Version : 0.2 -- Purpose: To specify the stack data type as discussed in class with its data types and operations -- Input : none -- Output : none -- Modifications: The MAX constant determines the maximum size of a given -- stack. -- -- Version 0.2 : An off-by-one error fixed in the type declaration of -- my array, and a typo fixed in the peek declaration. package stack is MAX : constant Integer := 20; type myArray is array (1..MAX) of Integer; type stackType is record top : Integer; -- alternate choice is top := 0 : Integer; aStack : myArray; MAXDATA : Integer := MAX; -- added to original specification end record; procedure push ( theStack : in out stackType; -- procedure to put an item on the stack theValue : in Integer); -- modifies stack procedure pop ( theStack : in out stackType; -- procedure to pop an item off the stack theValue : out Integer); -- modifies stack by removing the top value procedure peek ( theStack : in stackType; -- procedure to look at top of stack theValue : in out Integer); -- leaves stack unchanged procedure makeEmpty ( theStack : in out stackType ); -- creates an empty stack -- alters stack by setting top pointer function isFull ( theStack : in stackType ) return boolean; -- tests the stack for fullness -- doesn't alter stack function isEmpty ( theStack : in stackType ) return boolean; -- tests the stack for emptiness -- doesn't alter stack end stack;