Week 9 Exercise 20

280 views
Skip to first unread message

ivana...@gmail.com

unread,
Jan 3, 2016, 12:34:14 AM1/3/16
to mooc.fi
Hi,

I'm having problems with week  exercise 20.

The same problem has been reported: 10/29/15 by sander  there were comments but not solution. 

I'll rephrase the question below:

1) Error reported:
FAIL: SensorsAndTemperatureMeasurementTest averageSensorMethodMeasurementsWorks
Returned list should be empty with code
AverageSensor ka = new AverageSensor();
ka.addSensor( new ConstantSensor(3) );
ka.addSensor( new ConstantSensor(7) );
ka.readings();

2) Error analysis:
It seams that the TEST CASE expects ConstantSensor not to be added to the AverageSensor. However this requirement is not mentioned anywhere in the exercise. The only reference as to when the readings returned list should be empty is this: "If the measure method is called when the average sensor is off, or if the average sensor was not added any sensor, the method throws anIllegalStateException."
In the above TEST CASE the there is no indication that any sensor is off. At least one needs to be of in order for average sensor to be off. It seem that the TEST CASE itself is wrong.

3) QUESTION: I would appreciate clarification on the TEST CASE above. Why it expects reading list to be empty?

Best regards,
Ivana


Jarmo Isotalo

unread,
Jan 3, 2016, 10:33:09 AM1/3/16
to Ivana Bojic, mooc.fi
So, when the measure method is called, it should store the result to list, list which is accessible via the readings method.

So the readings method will just return the list. 
And since the sample code has not called measure for the AverageSensor the readings list should be empty.
In other words the readings returns only 'historical' data.

Hope this explains

-Jarmo

--
http://mooc.fi
---
You received this message because you are subscribed to the Google Groups "mooc.fi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moocfi+un...@googlegroups.com.
To post to this group, send email to moo...@googlegroups.com.
Visit this group at https://groups.google.com/group/moocfi.
To view this discussion on the web visit https://groups.google.com/d/msgid/moocfi/886147e4-3fcc-4c8a-bac5-b450690cb59b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ivana...@gmail.com

unread,
Jan 3, 2016, 2:21:05 PM1/3/16
to mooc.fi, ivana...@gmail.com
Hi Jarmo,

Thank you for clarification. I misunderstood the requirement below.

Add the method public List<Integer> readings() to your AverageSensor; it returns a list of the reading results of all the measurements executed through your AverageSensor.

I thought that:
a)  the measurements just calculate the average 
b)  the readings returns the readings of all the sensors

After your clarification:

a) the measurement calculates the average and store each average measurement in the array
b) the readings returns the list of all average measures

Now everything works.

Thanks,
Ivana

ivana...@gmail.com

unread,
Jan 3, 2016, 2:27:49 PM1/3/16
to mooc.fi, ivana...@gmail.com
How can I marked this question solved?

damekp...@gmail.com

unread,
Feb 12, 2016, 10:13:26 AM2/12/16
to mooc.fi, ivana...@gmail.com
I also misunderstood this from the specification. I feel it is not clearly worded, but this discussion cleared it up for me.
Reply all
Reply to author
Forward
0 new messages