MyArrayList practice problem

Many multiple choice and free response questions on the AP Computer Science Exam require you to manipulate arrays and lists. The MyArrayList practice problem is intended primarily as practice with arrays, though it also exposes you to list behavior.

The project requires you to insert elements into and delete elements from a partially filled array. It also requires you to traverse the array to find and remove an element that may or may not be present. You must declare new arrays and copy existing elements to them to enlarge or shrink the list.

MyArrayList instructions

Download the skeleton code for the MyArrayList class. Complete each skeleton method in the MyArrayList class so that the class behaves exactly the same as the java.util.ArrayList class for the same sequence of method calls. Do not import additional classes or declare additional instance fields.

Your class should throw the same exceptions as the real Java library class where appropriate. In these cases, the code to throw the exceptions has already been included. You just need to write the boolean conditions for which the expressions should be thrown.

Two test classes have been provided, both using the JUnit framework. Many Java IDEs (including Eclipse and BlueJ) support JUnit. tests most MyArrayList methods with precomputed test cases. tests a random sequence of calls to MyArrayList methods against the same sequence of calls run against a java.util.ArrayList.

See the MyArrayList solution or review it with AP CS Tutor Brandon Horn.

Get AP CS Help

Leave a Reply