Computer Science 241
Stack Assignment
Due: November 13, 2002

For this assignment, you are to implement a stack interface in two different ways: in an array and as a linked list.  The interface is:

package stack;
public interface StackInterface
{
     public boolean isEmpty ();
     public boolean isFull ();
     public void push (Node newNode);
     public Node pop ();
     public Node peek ();
} // interface StackInterface

Only the array implementation requires the isFull method, so in the linked implementation, just leave it with empty curly braces.  The peek method just returns the node at the top of the stack without changing the stack, while pop both returns the top node and moves the top pointer.

The two implementation classes should be called ArrayStack and LinkedStack.  They should both be in the stack package.  You should write a test class, but I will test the implementations with my own test class.  As long as your classes implement the interface, they should work with both.  Use the Node class shown below.  You may add methods to it if you want.

You may do this assignment alone or with one other student.  This is not a full group project.  Include documentation for both of your classes.

package stack;
import java.io.*;

public class Node
{
     protected String id, name;
     protected Node next;
 
     protected Node getNext () {return next;}
     protected void setNext (Node newNode) {next = newNode;}
 
     public void outputNode (PrintStream outfile)
     {
          outfile.println ("ID: " + id);
          outfile.println ("Name: " + name);
     } // method outputNode
} // class Node