Skip to content

Commit

Permalink
docs: add README instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasfara committed Nov 4, 2023
1 parent 9e51e8e commit 0058e53
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions java/inner-class/custom-iterable/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# INSTRUCTIONS

1. Implement the `IterableWithPolicy<T>` interface via a class that accepts two constructors (`constructor(T[])` and `constructor(T[], Predicate<T>)`):
1. The first constructor takes only **one** parameter which is the array of elements to iterate over. When this constructor is used, all the elements must be iterated.
2. The second constructor takes **two** parameters: `T[]` the array to iterate over and a [`Predicate`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/function/Predicate.html) that will be used to skip all the elements of the array that do not match the given predicate.
2. The method `setIterationPolicy(Predicate<T>)` must be implemented in such a way that it allows to change the iteration policy. The iteration policy is represented by the `Predicate` that is used to filter the elements of the array that do not match the given predicate.
3. Implement the `iterator()` method in such a way that it returns an instance of the `Iterator` interface that iterates over the elements of the array that match the iteration policy. (Hint: use an inner class)

0 comments on commit 0058e53

Please sign in to comment.