Let's begin building a simple list implementation that uses arrays to store the values.
Create a class SimpleArrayList with a public constructor that initializes the list using a passed array of
Object references. assert that the passed array is not null.
Next, implement:
Object get(int), which takes an int index and returns the Object at that indexvoid set(int, Object), which takes an int index and an Object reference and sets that value at the index
to the passed reference.Both your get and set method should assert that the index passed is valid for that SimpleArrayList.
Here's an example of how your SimpleArrayList should work:
Don't overthink this! Both get and set should be two lines of code (including one for the assert).
You're challenge is to write tests for this problem described above.
Stuck? You may find these lessons helpful: