CSCE 146

Lab 03

 

In this lab, you will be adding the following methods to the DoubleArraySeq class

  • The constructor

    public DoubleArraySeq(int initial capacity)
    {

    //implementation

    }
    This constructor initializes an empty sequence with a specified initial capacity.
  • The method

    public void addBefore(int element)
    {

    //implementation

    }
    This method adds a new element to the sequence, before the current element. If the capacity of the sequence exceeds the current capacity, then the capacity is increased before adding the element.
  • The method

    public void advance()
    {

    //implementation

    }
    This method moves the current element to the next element in the sequence. If the end of the sequence is reached, then there is no longer any current element.
  • The method

    public void ensureCapacity(int minimumCapacity)
    {

    //implementation

    }
    If the capacity of the sequence is less than initialCapacity, then the capacity is increased to initialCapacity.
  • The method

    public int getCapacity()
    {

    //implementation

    }
    This is an accessor method that returns the current capacity of the sequence.
  • The method

    public double getCurrent()
    {

    //implementation

    }
    This accessor method returns the current element in the sequence.
  • The method

    public boolean isCurrent()
    {

    //implementation

    }
    This method returns true if the sequence has a current element that can be determined with the getCurrent() method.
  • The method

    public int size()
    {

    //implementation

    }
    This method determines the number of elements in the sequence.
  • The method

    public void start()
    {

    //implementation

    }
    This method sets the current element to the first element in the sequence.
  • The method

    public void display()
    {

    //implementation

    }
    This method displays all the elements in the sequence.
  •