Due: Monday, February 27, 2017, 11:59 pm
The goal of this lab period is to give you an opportunity to implement a stack.
public IntStack( )a constructor that makes an array of 10 ints and initialize the top index to be 0.
public void push( int new_item )pushes a new item onto the stack. If there isn't enough room in the array, then create a new array and copy the data over. The size of the new array equals to 2 * the size of the old array.
public int pop()pops an item off the stack and returns it.
public int elementAt( int index )returns the element at the given position (do not modify the stack).
public int size()returns the number of items in the stack.
public boolean isEmpty()returns true if the stack is empty.
Once you have completed the lab and feel comfortable with stacks, go on to Project 3.
© 2017 Ying Li. Page last modified: .