CSCE 146

Lab 06

 

In this lab, you will implement a stack data structure which contains characters. Your class should implement the following methods:

  • The constructor

    public CharStack()
    {

    //implementation

    }
    This constructor initializes the stack.
  • The method

    public void push(char element)
    {

    //implementation

    }
    This method pushes a character onto the Top of Stack.
  • The method

    public char pop()
    {

    //implementation

    }
    This method removes and returns the topmost element of the stack.
  • The method

    public char peek()
    {

    //implementation

    }
    This method returns the element at the Top of Stack, wothout removing it from the stack.
  • The method

    public boolean isEmpty()
    {

    //implementation

    }
    This method returns true if the stack is empty and false otherwise.the sequence.
  • The method

    public int size()
    {

    //implementation

    }
    This method returns the number of elements in the stack.
  •