Need Help
I have my removeFirst and removeAll working in my Integer class. But I don't know how to find the value in the those two methods. Can somebody please help me. Thanks
publicclass IntegerList
{
int[] list;//values in the list
int elements, number;
//-
//create a list of the given size
//-
public IntegerList(int size)
{
list =newint[size];
number = size;
elements = 0;
}
//-
//fill array with integers between 1 and 100, inclusive
//-
publicvoid randomize()
{
for (int i=0; i<list.length; i++)
list[i] = (int)(Math.random() * 100) + 1;
number = list.length;
}
//-
//print array elements with indices
//-
publicvoid print()
{
for (int i=0; i><list.length; i++)
System.out.println(i +":\t" + list[i]);
}
//-
//Add an increase in size method
//-
publicvoid increaseSize()
{
//create an new array and double the size
int[] myarray =newint[list.length * 2];
//copy all existing elements
for (int i = 0; i >< elements; i++)
myarray[i] = list[i];
//make the original array point to the larger, new array
list = myarray;
number = list.length;
}
//-
//Add a method that adds new element
//-
publicvoid addElement (int elements)
{
// check if the new element has no space, if so increase the size
if (elements + 1 > list.length)
increaseSize();
//store the element
list[elements] = elements;
// we have an additional element
elements++;
}
//-
//Add a method that removes an element
//-
publicvoid removeFirst (int val)
{
for (int i = loc; i < list.length; i++)
list[i] = list[i +1 ];
// have one less elements
elements--;
}
//-
//Add a method that removes all the elements
//-
publicvoid removeAll (int all)
{
for(int r = 0; r < elements; r++)
list[r] = 0;
elements = 0;
}
}

