csc241.samples.Stack
Interface Stack

All Known Implementing Classes:
dynamicStack, fixedStack

public interface Stack

~mohammad/public_html/classes/csc241/Stack/Stack.java This is an ADT for stack. A Stack holds objects. There is no code, private variables, or constructors designed for Stack as it is an Interface. We are postponing the implementation, so that we could have an array version and a linked list version. Notice that there is no constructor and instead of {} for the methods with simply have ';'.


Method Summary
 boolean empty()
          return true if stack is empty, otherwise, return false
 boolean full()
          return true if stack is full, otherwise, return false
 csc241.samples.Stack.Stack pop()
          remove an element from the top of the stack.
 csc241.samples.Stack.Stack push(java.lang.Object x)
          add an element to the top of the stack.
 java.lang.Object top()
          return the element on top of the stack; return null if empty.
 

Method Detail

empty

public boolean empty()
return true if stack is empty, otherwise, return false


full

public boolean full()
return true if stack is full, otherwise, return false


push

public csc241.samples.Stack.Stack push(java.lang.Object x)
                                throws stackException
add an element to the top of the stack.
x - the Object to be added

Throws:
- - Exception if stack is full
stackException

pop

public csc241.samples.Stack.Stack pop()
                               throws stackException
remove an element from the top of the stack.

Throws:
- - Exception if stack is empty.
stackException

top

public java.lang.Object top()
return the element on top of the stack; return null if empty.