Remember, the labs are not for credit, just for practice! But that means you have to do them to learn anything.
Finish the 5 methods in
ArrayList. Be sure to follow the
ListInterface specification closely!
You can test your
Ex22ArrayList as the driver program.
2. Making a linked list implementation
Now make a
LinkedList class which also implements
ListInterface. Go have a look at
LinkedBag to refresh your memory on how to manage linked lists.
It should behave exactly like
ArrayList did, at least externally.
3. Making a
Finally, make an interface
SortableList which extends
ListInterface. Remember what constraint you must put on the type parameter to make it sortable.
It should add two methods:
sort() will sort the items in ascending order.
int bsearch(E) will perform a binary search on the list for the given item, similar to
indexOf (it will return -1 if the item is not found).
Specify those methods thoroughly in
SortableList. Then try implementing them in a class
SortableArrayList which extends
ArrayList. You can use the
protected members from that class in your derived class.