Difference between revisions of "DoubleDeltaRange"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
=Motivation= | =Motivation= | ||
− | Experience implementing the [https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html Iterable<T>] | + | Experience implementing the [https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html Iterable<T>] and [https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html Iterator<T>] interfaces. |
=Mistakes To Avoid= | =Mistakes To Avoid= | ||
Line 6: | Line 6: | ||
=Investigate= | =Investigate= | ||
− | interface [https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html Iterable<T>] | + | * interface [https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html Iterable<T>] |
− | + | * interface [https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html Iterator<T>] | |
− | interface [https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html Iterator<T>] | ||
<youtube>Dww-_5EiwA8</youtube> | <youtube>Dww-_5EiwA8</youtube> | ||
Line 18: | Line 17: | ||
<pre>class DoubleDeltaRange implements Iterable<Double></pre> | <pre>class DoubleDeltaRange implements Iterable<Double></pre> | ||
− | {{CodeToImplement|DoubleDeltaRange|constructor<br/>iterator()| | + | {{CodeToImplement|DoubleDeltaRange|constructor<br/>iterator()|iteration.doubledelta.group}} |
===constructor=== | ===constructor=== | ||
Line 30: | Line 29: | ||
=Testing Your Solution= | =Testing Your Solution= | ||
==Correctness== | ==Correctness== | ||
− | {{TestSuite| | + | {{TestSuite|_DoubleDeltaRangeTestSuite|iteration.doubledelta.group}} |
Revision as of 16:52, 27 January 2022
Contents
Motivation
Experience implementing the Iterable<T> and Iterator<T> interfaces.
Mistakes To Avoid
Warning: Do NOT Parallelize |
Investigate
- interface Iterable<T>
- interface Iterator<T>
Code to Implement
DoubleRange
To implement this class you will need to declare and initialize fields. You should NOT create a List<Double> and fill it with the necessary values. The iterator should produce each next value live.
class DoubleDeltaRange implements Iterable<Double>
class: | DoubleDeltaRange.java | |
methods: | constructor iterator() |
|
package: | iteration.doubledelta.group | |
source folder: | student/src/main/java |
constructor
method: public DoubleDeltaRange(double minInclusive, double maxExclusive, double delta)
(sequential implementation only)
iterator()
method: public Iterator<Double> iterator()
(sequential implementation only)
Although, you can create a named class, we encourage you to use this opportunity to create an instance of an anonymous class here.
Testing Your Solution
Correctness
class: | _DoubleDeltaRangeTestSuite.java | |
package: | iteration.doubledelta.group | |
source folder: | testing/src/test/java |