org.jwalk.test
Class Stack

java.lang.Object
  extended by org.jwalk.test.Stack

public class Stack
extends java.lang.Object

Stack is a fixed-length, bounded implementation of a push-down Stack. This is a standard test class, provided with the JWalk tool suite. The Stack has storage capacity for five objects and overflows if more objects are pushed. Popping the Stack returns it to a previous state (removed objects are replaced by null).

This test class can be used to demonstrate the ability of an AlgebraWalker to discover the algebraic structure of a Stack data type. Eventually, there are no more test sequences to discover, since all long paths eventually re-enter previously visited states. Primitive, transformer and observer operations may be identified.

This test class can also be used to demonstrate the ability of a StateSpaceWalker to discover the high-level state space of a Stack data type. Two natural predicates of the type are used to identify three high-level states. The state cover set is identified. Note: if the JWalker's probe depth is set to less than 5, the tool should correctly report that it failed to find the expected full-state.

Version:
1.0
Author:
Anthony J H Simons

Constructor Summary
Stack()
          Creates a Stack with a maximum capacity for five elements.
 
Method Summary
 boolean isEmpty()
          Reports if this Stack is empty.
 boolean isFull()
          Reports if this Stack is full.
 void pop()
          Pops an object off this Stack.
 void push(java.lang.Object item)
          Pushes an object onto this Stack.
 int size()
          Reports the dynamic size of this Stack.
 java.lang.Object top()
          Returns the top object on this Stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stack

public Stack()
Creates a Stack with a maximum capacity for five elements.

Method Detail

push

public void push(java.lang.Object item)
Pushes an object onto this Stack.

Parameters:
item - an object.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if this Stack is full.

pop

public void pop()
Pops an object off this Stack.

Throws:
EmptyStackException, - if this Stack is empty.

top

public java.lang.Object top()
Returns the top object on this Stack.

Returns:
the top object.
Throws:
EmptyStackException, - if this Stack is empty.

size

public int size()
Reports the dynamic size of this Stack.


isEmpty

public boolean isEmpty()
Reports if this Stack is empty.

Returns:
true, if there are no pushed elements.

isFull

public boolean isFull()
Reports if this Stack is full.

Returns:
true, if there are five pushed elements.