{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

StackAr - package DataStructures StackAr class CONSTRUCTION...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
package DataStructures; // StackAr class // // CONSTRUCTION: with or without a capacity; default is 10 // // ******************PUBLIC OPERATIONS********************* // void push( x ) --> Insert x // void pop( ) --> Remove most recently inserted item // Object top( ) --> Return most recently inserted item // Object topAndPop( ) --> Return and remove most recently inserted item // boolean isEmpty( ) --> Return true if empty; else false // boolean isFull( ) --> Return true if full; else false // void makeEmpty( ) --> Remove all items // ******************ERRORS******************************** // Overflow and Underflow thrown as needed /** * Array-based implementation of the stack. * @author Mark Allen Weiss */ public class StackAr { /** * Construct the stack. */ public StackAr( ) { this( DEFAULT_CAPACITY ); } /** * Construct the stack. * @param capacity the capacity. */ public StackAr( int capacity ) { theArray = new Object[ capacity ]; topOfStack = -1; } /** * Test if the stack is logically empty. * @return true if empty, false otherwise.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 3

StackAr - package DataStructures StackAr class CONSTRUCTION...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online