This is my first time doing vectors in Java and I am a bit rusty at java as it is and would appreciate any help.
I have to have a method called
boolean addGroup(Vector objects, int start) – This method adds the elements in the vector argument to the list, starting at position start in the list and preserving the vector order. Be mindful of the CPU performance of your solution. You may assume that the list/array will always be big enough to take the additional objects.
This is what i have done so far in LinkList
Test:public boolean addGroup(Vector<Object> objects, int start)
{
boolean result = false;
{
Vector<Object>a = new Vector<Object>();
a.addAll(objects);
result = true;
}
return result;
}
I have created a method called populateVector() to make it easier for making my test class:public void testAddGroup()
{
populateList();
assertTrue(lList.getLength() == 2);
populateVector();
boolean result = lList.addGroup(films, 1);
assertTrue(result);
assertTrue(lList.getLength() == 8);
assertEquals(film3, lList.getEntry(3));
assertEquals(film7,lList.getEntry(7)) ;
assertNull(lList.getEntry(9)) ;
}
private void populateVector()
{
films.add(film3);
films.add(film4);
films.add(film5);
films.add(film6);
films.add(film7);
films.add(film8);
}