Testing the Methods That Remove Strings
In this lesson, we will test the methods remove and clear.
We'll cover the following
Testing remove
and clear
Our class BagOfStrings
is essentially complete. Since we have tested all methods except remove
and clear
, we assume that they are correct. The program BagDemo3
removes strings from an empty bag, a full bag, and a bag that is neither empty nor full. In addition to the methods addToBag
and displayBag
from our earlier tests, BagDemo3
defines another method—removeFromBag
—that removes a given string from a given bag. If the given string is null
, the method will call our first remove
method that removes one unspecified string from the bag. Otherwise, it will remove the given string. Click the RUN button to see the results of these tests.
Get hands-on with 1400+ tech skills courses.