The post lab 2 assignment involves storing an unknown number of
objects in a list. This is similar to the CDCollection class from
last semester where the array was able to expand to fit more
objects if necessary. Instead of rewriting classes that store
objects in expanding arrays every time we need one, we are going
to take advantage of inheritance to write one class that can store
an array of any other class. We can do this by creating a class
that manages an array of Objects, which all classes are
descendants of. The
file ArrayList.java contains an
outline for such a class. It has an array of Objects for an
instance variable, a constructor that initializes an empty list, a
method that adds an object to the list, a method to get objects in
the list, a method to get the number of objects in the list, and a
toString
method. Complete the methods as specified
in the method comments.
Submission: Submit your code as a zip file with your name as the zip file name on the course Inquire site.