CJCoding With Joseph
15free / daySign inCreate account

Sensor is an abstract class, but its read() method is still an ordinary method with a made-up body that returns 0.0. A method that only subclasses can answer should be declared abstract: a header that ends in a semicolon, with no body at all. Then the compiler makes every subclass write its own read().

Requirements: 1. Replace the placeholder read() with an abstract method that has the same name, is public, takes no parameters and returns a double. 2. Leave the constructor, getLabel() and status() as they are. status() keeps calling read(). 3. The tests bring their own subclasses, such as a Thermometer whose read() returns 21.5. They print status(), and they also check that read() is declared abstract.

Do NOT write a main method.

Expected output

Thermometer: 21.5
read is abstract: true

= newline. The output ends with a newline, so print one after the last line.

Hints2 available
Topics
Abstract ClassesClasses
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.