2014-11-06 SuperArray Lab

posted Nov 6, 2014, 8:36 AM by Samuel Konstantinovich   [ updated Nov 12, 2014, 2:55 PM ]
Write the SuperArray class. You can test your SuperArray by adding Integer objects.

//Example of ways to add Integer objects:
Integer x = new Integer(5);
SuperArray L = new SuperArray();
L.add(new Integer(99));

1. Instance variables:
   1a. An array of Objects
   1b. An int that stores the current number of stored elements.

2. The methods to allow you to use the SuperArray.

Default constructor  : 
                    create an empty SuperArray with a capacity of 10;

Constructor that takes a size:
                    create an empty SuperArray that starts with the indicated capacity.  

String toString()
                    return a string representation of the array. Use the format:  "[ e1 e2 e3 ... ]"

void add(Object e)
                    append the specified Object to the end of the list

int size():         return the number of elements in the list

void resize(int newCapacity)
                    make a new array of size newCapacity, copy all of the values over from the SuperArray, and replace the SuperArray's array with the newly created array.

////////////////////////You may start on these extra methods when you are done://////////////////////

void clear():       removes all of the elements from the list

Object get(int index)
                    return the object located at the specified position

void set(int index, Object e): 
                    set the object located at the specified position to the specified value.