
public class SimpleList implements IList {

	private static final int INIT_SIZE = 10;
	
	protected Object[] myCon;
	private int mySize;
	
	public SimpleList(){
		myCon = new Object[INIT_SIZE ];
		mySize = 0;
	}
	
	public void add(Object x) {
		if( size() == myCon.length )
			resize();
		myCon[mySize] = x;
		mySize++;
	}
	
	protected void resize(){
		Object[] temp = new Object[size() * 2];
		System.arraycopy(myCon, 0, temp, 0, size());
		myCon = temp;
	}
	
	public int size() {
		return mySize;
	}

	public Object get(int loc) {
		return myCon[loc];
	}

	public Object remove(int loc) {
		for(int i = loc; i < mySize - 1; i++){
			assert 0 <= i && i < myCon.length;
			myCon[i] = myCon[i+1];
		}
		return myCon[loc];
	}
	
	public void clear(){
		myCon = new Object[10];
		mySize = 0;
	}
}
