Overall Goal:
Add the provided item to the array. You will need to increase the array size and add the new item to the end of the list. If the name already exists (case does not matter) don't add the item. No External Classes Permitted to Be Used in This Method Apart From String.toUpperClass
and String.Equals
.
In order to do this I have written the following:
public int addItem(Item newItem) {
itemList = Arrays.copyOf(itemList, +1);
int done=-1;
for (int i=0;i<itemList.length;i++){
itemList[i]=newItem;
done=(i+1);
}
return done;
}
To test this section of code I am using a JUnit tester which fails with the following exception:
error: AddItem: Put a single item in and make sure its in the right place: expected:<[item2]> but was <[item1]>.