-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotifiers.cpp
More file actions
58 lines (48 loc) · 1.27 KB
/
Copy pathnotifiers.cpp
File metadata and controls
58 lines (48 loc) · 1.27 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <string>
using namespace std;
// void SendSms(const string &number, const string &message)
// {
// cout << "Send '" << message << "' to number " << number << endl;
// }
// void SendEmail(const string &email, const string &message)
// {
// cout << "Send '" << message << "' to e-mail " << email << endl;
// }
class INotifier
{
public:
INotifier(const string &dest) : destination_(dest) {}
virtual void Notify(const string &message) const = 0;
const string destination_;
};
class SmsNotifier : public INotifier
{
public:
SmsNotifier(const string &dest) : INotifier(dest) {}
void Notify(const string &message) const override
{
SendSms(destination_, message);
}
};
class EmailNotifier : public INotifier
{
public:
EmailNotifier(const string &dest) : INotifier(dest) {}
void Notify(const string &message) const override
{
SendEmail(destination_, message);
}
};
// void Notify(INotifier ¬ifier, const string &message)
// {
// notifier.Notify(message);
// }
// int main()
// {
// SmsNotifier sms{"+7-495-777-77-77"};
// EmailNotifier email{"na-derevnyu@dedushke.ru"};
// Notify(sms, "I have White belt in C++");
// Notify(email, "And want a Yellow one");
// return 0;
// }