-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAverager.hpp
38 lines (30 loc) · 1.02 KB
/
Averager.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// Averager.hpp
// HW4_R
//
// Created by Kaloyan Vachkov on 25.05.21.
//
#ifndef Averager_hpp
#define Averager_hpp
#include "Subscriber.hpp"
// You are not allowed to make breaking changes to the class interface,
// but you are allowed to add additional methods/fields, as
// well as MODIFY the existing interface so as to make it
// "more correct" and more compact if possible
// Averager is a type of Subscriber, which saves data and
// returns the average of the data when `read()` is called.
// Data is provided with the `signal()` method.
// Average of N numbers = sum(all numbers) / N
class Averager : public Subscriber {
public:
Averager(const std::string& id);
// id is a unique identifier for a Subscriber
// Should never be changed once initialized
//const std::string id;
// signal adds a new data point
//void signal(const Message&);
// read calculates the average of all data points provided so far
// returns 0 if there's no data points
int read()const override;
};
#endif /* Averager_hpp */