A stack is a list that follows the last-in-first-out (LIFO)
principle. An example is a stack of cafeteria trays. You take
the top one, which is the last one that the staff put in.

Package CS2110Stacks contains interface Stack, which has the stack
methods as abstract methods. The package contains three implementations:

  1. ArrayStack implements it using an array --and shows you what
     to do when an array needs more elements
  2. LinkedListStackIt uses a linked list, with iteration being used
     instead of recursion.
  3. LinkedListStackRe uses a linked list, with recursion being used
     instead of iteration.

In addition, to show how to do such things, each implementation
provides operation not usually found with stacks:

  1. Delete the top occurrence of a particular object e (if present)
  2. Tell whether the stack contains a particular element
  3. Reverse the stack --turn it upside down.

These operations are not included in  interface because they are not
typical stack operations.

Note how file Stack.java has not only public class Stack but also class
StackCell; because it does not have an access modifier, it is by default
access "package", which means the class can be used only in classes/interfaces
within this package, and not outside this package. Since the user won't
refer directly to class StackCell, it's OK to make its fields public and
omit getter/setter functions.

Class StackTester, the only one we did not put in package CS2110Stacks,
is a JUnit testing class, which tests all three implementations of Stack.

You will see the word "prepend" in the classes. To append means to add
at the end. There was no word for adding at the beginning, until Gries
coined the word prepend for it, about 20 years ago.

David Gries