csc241.samples.Stack
Class fixedStack

java.lang.Object
  |
  +--csc241.samples.Stack.fixedStack
All Implemented Interfaces:
Stack

public class fixedStack
extends java.lang.Object
implements Stack

~mohammad/public_html/classes/csc241/Stack/fixedStack.java This version implements Stack using an array. top_ indexes the top location of the array.


Constructor Summary
fixedStack(int size)
          construct a fixedStack
 
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 val)
          add an element to the top of the stack.
 java.lang.Object top()
          return the element on top of the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

fixedStack

public fixedStack(int size)
construct a fixedStack

Method Detail

empty

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

Specified by:
empty in interface Stack

full

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

Specified by:
full in interface Stack

pop

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

Specified by:
pop in interface Stack
Throws:
- - Exception if stack is empty.
stackException

push

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

Specified by:
push in interface Stack
Throws:
- - Exception if stack is full
stackException

top

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

Specified by:
top in interface Stack
Throws:
- - Exception if stack is empty.