Difference between revisions of "DoubleDeltaRange"

From CSE231 Wiki
Jump to navigation Jump to search
Line 16: Line 16:
 
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.
 
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.
  
<pre>class DoubleRange implements Iterable<Double></pre>
+
<pre>class DoubleDeltaRange implements Iterable<Double></pre>
  
{{CodeToImplement|DoubleRange|constructor<br/>iterator()|doublerange.warmup}}
+
{{CodeToImplement|DoubleDeltaRange|constructor<br/>iterator()|doublerange.warmup}}
  
 
===constructor===
 
===constructor===
{{Sequential|public DoubleRange(double minInclusive, double maxExclusive, double delta)}}
+
{{Sequential|public DoubleDeltaRange(double minInclusive, double maxExclusive, double delta)}}
  
 
===iterator()===
 
===iterator()===
Line 30: Line 30:
 
=Testing Your Solution=
 
=Testing Your Solution=
 
==Correctness==
 
==Correctness==
{{TestSuite|DoubleRangeTestSuite|doublerange.warmup}}
+
{{TestSuite|DoubleDeltaRangeTestSuite|doublerange.warmup}}

Revision as of 16:48, 27 January 2022

Motivation

Experience implementing the Iterable<T> interface.

Mistakes To Avoid

Attention niels epting.svg 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 Java.png
methods: constructor
iterator()
package: doublerange.warmup
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

Correctness

class: DoubleDeltaRangeTestSuite.java Junit.png
package: doublerange.warmup
source folder: testing/src/test/java