Difference between revisions of "DoubleDeltaRange"

From CSE231 Wiki
Jump to navigation Jump to search
Line 28: Line 28:
  
 
=Testing Your Solution=
 
=Testing Your Solution=
 +
==Client==
 +
{{Client|DoubleDeltaRangeClient|iteration.doubledelta.client|main}}
 +
 +
<nowiki>DoubleDeltaRange range = new DoubleDeltaRange(3.0, 5.0, 0.25);
 +
for (double d : range) {
 +
System.out.println(d);
 +
}</nowiki>
 +
 +
should produce the output:
 +
 +
<nowiki>3.0
 +
3.25
 +
3.5
 +
3.75
 +
4.0
 +
4.25
 +
4.5
 +
4.75</nowiki>
 +
 
==Correctness==
 
==Correctness==
 
{{TestSuite|_DoubleDeltaRangeTestSuite|iteration.doubledelta.group}}
 
{{TestSuite|_DoubleDeltaRangeTestSuite|iteration.doubledelta.group}}

Revision as of 17:53, 30 January 2023

Motivation

Experience implementing the Iterable<T> and Iterator<T> interfaces.

Mistakes To Avoid

Attention niels epting.svg Warning: Do NOT Parallelize

Investigate

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 Java.png
methods: constructor
iterator()
package: iteration.doubledelta.group
source folder: student/src/main/java

constructor

method: public DoubleDeltaRange(double minInclusive, double maxExclusive, double delta) Sequential.svg (sequential implementation only)

iterator()

method: public Iterator<Double> iterator() Sequential.svg (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

Client

class: DoubleDeltaRangeClient.java CLIENT
package: iteration.doubledelta.client
source folder: student/src/main/java
DoubleDeltaRange range = new DoubleDeltaRange(3.0, 5.0, 0.25);
for (double d : range) {
	System.out.println(d);
}

should produce the output:

3.0
3.25
3.5
3.75
4.0
4.25
4.5
4.75

Correctness

class: _DoubleDeltaRangeTestSuite.java Junit.png
package: iteration.doubledelta.group
source folder: testing/src/test/java