#include <iostream>
class ADCSensor {
private:
const int offset_val;
public:
// TODO: The offset should be an internal implementation detail.
// TODO: Encapsulate this to prevent external modification.
ADCSensor() : offset_val(100) {}
// TODO: Add a method to process raw values and return calibrated data.
int getCalibratedSample(int raw) const {
int calibrated = raw - offset_val;
if (calibrated <0) {
return 0;
}
return calibrated;
}
};
int main() {
int N;
if (!(std::cin >> N)) return 0;
ADCSensor sensor;
for (int i = 0; i < N; ++i) {
int raw;
std::cin >> raw;
// TODO: Move this logic inside the class.
// TODO: Fix the bug where (raw - offset) can be negative.
std::cout << "Sample: " << sensor.getCalibratedSample(raw) << std::endl;
}
return 0;
}
Input
3 250 100 50
Expected Output
Sample: 150 Sample: 0 Sample: 0