Class MysteryStackImplementation<T>

java.lang.Object
  extended by MysteryStackImplementation<T>
Type Parameters:
T - The type of data that the stack stores.
All Implemented Interfaces:
Stack<T>

public class MysteryStackImplementation<T>
extends java.lang.Object
implements Stack<T>

An implementation of the Stack ADT.


Constructor Summary
MysteryStackImplementation()
          Default constructor: creates an empty stack.
 
Method Summary
 void clear()
          Removes all items from the stack.
 boolean isEmpty()
          Returns true if the stack is empty.
static void main(java.lang.String[] args)
           
 T peek()
          Return the top item from the stack but don't remove it.
 T pop()
          Remove the top item from the stack and return it.
 void push(T item)
          Store an item in the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MysteryStackImplementation

public MysteryStackImplementation()
Default constructor: creates an empty stack.

Method Detail

push

public void push(T item)
Store an item in the stack.

Specified by:
push in interface Stack<T>
Parameters:
item - The item to add.

pop

public T pop()
Remove the top item from the stack and return it.

Specified by:
pop in interface Stack<T>
Returns:
the item at the top of the stack, or null if empty.

peek

public T peek()
Return the top item from the stack but don't remove it.

Specified by:
peek in interface Stack<T>
Returns:
the item at the top of the stack, or null if empty.

isEmpty

public boolean isEmpty()
Description copied from interface: Stack
Returns true if the stack is empty.

Specified by:
isEmpty in interface Stack<T>

clear

public void clear()
Description copied from interface: Stack
Removes all items from the stack.

Specified by:
clear in interface Stack<T>

main

public static void main(java.lang.String[] args)