L04

Due by the end of today by midnight

Starter Files:


SUBMIT   /   Submission Summary

Good Programming Practices

Activity 1
Download the Bag interface and the ArrayBag data type. Examine the code.

Notice that there are several methods in ArrayBag that are currently throwing UnsupportedOperationExceptions:

Implement the containsAll and addAll methods.

containsAll returns true if this ArrayBag contains each and every item in the Collection it was given.

You will note that the given Collection has base type ?. That means the Collection can be of any type. That's fine, because the ArrayBag's contains method can be given any type of Object.

addAll adds every item from the given Collection and returns true if the contents of this ArrayBag changed.

You will note that the given Collection has base type ? extends T. That means the Collection can be of any type that extends the base type of this ArrayBag. That means that every item in that Collection is some kind of T, and so the ArrayBag's add method will accept it.

Submit this/these files:


SUBMIT   /   Submission Summary