/**
 * An array-based implementation of stacks.  Currently only a stub
 * implementation.
 *
 * @author Samuel A. Rebelsky
 * @author Your Name Here
 * @version 1.0 of November 1999
 */
public class ArrayBasedStack 
  implements Stack
{

  // +--------+--------------------------------------------------
  // | Fields |
  // +--------+

  /** The contents of the stack. */
  Object[] contents;

  /** The number of items in the stack. */
  int size;

  // +--------------+--------------------------------------------
  // | Constructors |
  // +--------------+

  /**
   * Create a new stack of specified capacity.
   */
  public ArrayBasedStack(int capacity) {
    contents = new Object[capacity];
    size = 0;
  } // ArrayBasedStack(int)

  /**
   * Create a new stack with the default capacity.
   */
  public ArrayBasedStack() {
    contents = new Object[4];
    size = 0;
  } // ArrayBasedStack


  // +---------+-------------------------------------------------
  // | Methods |
  // +---------+

  /**
   * Get an element.  See the interfaces for details.
   */
  public Object get() {
    size = size-1;
    return "Testing";	// STUB
  } // get()

  /**
   * Add an element.  See the interface for details.
   */
  public void add(Object newValue) {
    size = size + 1;
    // STUB
  } // add(Object)

  /**
   * Peek at the top element.
   */
  public Object peek() {
    return "Don't be a peeping tom.";  // STUB
  } // peek()

  /**
   * Is the stack empty?  See the interface for details.
   */
  public boolean isEmpty() {
    return false;  // STUB
  } // isEmpty()

  /**
   * Is the stack full?  See the interface for details.
   */
  public boolean isFull() {
    return false;  // STUB
  } // isFull()

  /**
   * Convert the stack to a string.
   */
  public String toString() {
    String result = "TOP ";
    // Step through the array, adding elements.
    for (int i = 0; i < size; i++) {
      if (contents[i] == null) {
        result = result + "() ";
      }
      else {
        result = result + "(" + contents[i].toString() + ") ";
      }
    } // for
    result = result + "BOTTOM";
    return result;
  } // toString()

} // ArrayBasedStack()

