increaseSize and addElement help
Im currently working on a project that asks for:
It is often necessary to add items to or remove items from a list. When the list is stored in an array, one way to do this is to
create a new array of the appropriate size each time the number of elements changes, and copy the values over from the old
array. However, this is rather inefficient. A more common strategy is to choose an initial size for the array and add elements
until it is full, then double its size and continue adding elements until it is full, and so on.
1. Add this capability to the IntegerList class. You will need to add an increaseSize method plus instance variables to hold
the current number of integers in the list and the current size of the array. Since you do not have any way to add elements
to the list, you won't need to call increaseSize yet.
2. Add a method void addElement(int newVal) to the IntegerList class that adds an element to the list. At the beginning of
addElement, check to see if the array is full. If so, call increaseSize before you do anything else.
I tried googling both things but I dont understand them. Can anyone explain to me what they are for, more precisely, and how do I use em.
If possible, can anyone show me examples of how to use em.
Also, I need help on how to insert in into the the IntegerList class that can be found on the link below.
The program Im working on can be found here: cs.roanoke.edu/~cpsc/AW/labs/ch6/IntegerListII.html
Thank you anyone who helps!!!