Im writing an arraylist class with iterators and I believe i have a .docx

This preview shows page 1 - 6 out of 14 pages.

Background image
Im writing an arraylist class with iterators and I believe i have a decent amount done.I basically need someone to look over it and say "this here and here will work, and this method over there (with your variables) should probably be like this.import java.util.*;/*** ArrayList represents an array implementation of a list. Thefront of* the list is kept at array index 0. This class will be extended* to create a specific kind of list.** @author Java Foundations* @version 4.0*/public abstract class AbstractArrayList<T> implements ListADT<T>{private final static int DEFAULT_CAPACITY = 100;��private final static int NOT_FOUND = -1;��protected int rear;��protected T[] list;��protected int modCount,itemCount;��int oldCapacity;��/**��* Creates an empty list using the default capacity.��*/��
public AbstractArrayList()��{��this(DEFAULT_CAPACITY);�� ���oldCapacity=100;�� ���}��/**��* Creates an empty list using the specified capacity.��*��* @param initialCapacity the integer value of the size ��of the array list*/��public AbstractArrayList(int initialCapacity)��{��rear = 0;�� ���list = (T[])(new Object[initialCapacity]);�� ���modCount = 0;�� ���oldCapacity=initialCapacity;�� ���}��/**��* Creates a new array to store the contents of this list ��with* twice the capacity of the old one. Called by ��descendant classes* that add elements to the list.��*/��protected void expandCapacity()��{��//TODO To be checked�� ���
int newCapacity = (oldCapacity*3)/2+1;�� ���oldCapacity=newCapacity;�� ���}��/**��* Removes and returns the last element in this list.��*��* @return the last element in the list��* @throws EmptyCollectionException if the element is ��not in the list*/��public T removeLast() throws ��EmptyCollectionException{��//TODO To be completed�� ���try�� ���{�� ����� ��� ���}�� ���catch(EmptyCollectionException ece)�� ���{�� ����� ��� ���}�� ���itemCount--;�� ���}��/**��* Removes and returns the first element in this list.��*��* @return the first element in the list��
* @throws EmptyCollectionException if the element is ��not in the list*/��

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture