// Import ArrayList to implement the stack
import java.util.ArrayList;
// Import the GDSV libraries
import gdsv.*;


// Make sure that our data structure implements GenericDataStructureViewable!
public class ArrayStack implements GenericDataStructureViewable {
    
    public ArrayList stack;
    
    public ArrayStack() {
        stack = new ArrayList();
    }
    
    // IMPORTANT! Make sure to realize this method.
    // This method returns the Array Representation of the data structure.
    // For a complete list/sample code/help on this, please visit the website
    public Object[] arrayRepresentationOfDataStructure() {
        return stack.toArray();     // Return the ArrayList's array representation.
    }
    
    public void push(Object object) {
        stack.add(0,object);
    }
    
    public Object pop() {
        return stack.remove(0);
    }
    
    public Object peekTop() {
        return stack.get(0);
    }
    
    public boolean isEmpty() {
        return stack.size()==0;
    }
    
}