Exercise Foundation: Sensor Hierarchy

Hypothetical

We are an organization that sits on a large pile of software. Sensors, temperature sensors actually, are fundamental in that pile, and there are many sensor implementations around. All are organized in a class hierarchy, starting at an abstract base class (an interface):

#pragma once

class Sensor
{
public:
    virtual ~Sensor() {}

    // returns degrees Celsius
    virtual double get_temperature() = 0;
};

Two concrete implementations of such sensors that we will use in the exercise series in this course are:

  • RandomSensor. That sensor yields floating point random numbers in a configurable range.

  • ConstantSensor. That one yield always the same temperature. Cool for testing.

We will extend that hierarchy along with the exercises.

Class Hierarchy

../../../../_images/sensor-hierarchy.png