Task 3:
Look at the first two variants of the orMap
method (the
recursively defined variant and the variant that uses the
while
loop. Identify
the four parts (BASE-VALUE, Termination/Continuation PREDICATE,
UPDATE, and ADVANCE) in each of them.
Look also at the tests in the Examples
class.
After you understand how the while
loop works, design two
variants of the
method that produces a new ArrayList
that contains all
elements of the original list that satisfy the given ISelect
predicate.
Test the methods by producing all red balloons or all small balloons.
Design and test two variants of the andMap
method that determines whether all elements of a given list satisfy
the given ISelect
predicate.
Test the methods by checking whether a list contains all red balloons or all small balloons.
If you have the time left, repeat all the parts of Task 3 with
the remaining two variants of the orMap
— namely the one
that uses the for
loop with the Traversal
and the
one that uses counted for
loop.