-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInterfaceSegregationPrinciple.cpp
80 lines (60 loc) · 1.37 KB
/
InterfaceSegregationPrinciple.cpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// Created by Amit Kumar on 24/09/23.
//
#include <iostream>
using namespace std;
class PhotoManager {
public:
virtual void takePhoto() = 0;
};
class PowerManager {
public:
virtual void powerOn() = 0;
virtual void powerOff() = 0;
};
class MusicManager {
public:
virtual void playMusic() = 0;
};
class BatteryManager {
public:
virtual void chargeBattery() = 0;
};
class Phone: public PhotoManager, public PowerManager, public MusicManager, public BatteryManager{
public:
void powerOn() override {
cout << "power on" << endl;
}
void powerOff() override {
cout << "power off" << endl;
}
void playMusic() override {
cout << "playing music " << endl;
}
void chargeBattery() override {
cout << "charging battery" << endl;
}
void takePhoto() override {
cout << "clicking photo" << endl;
}
};
class Camera: public PowerManager, public BatteryManager, public PhotoManager{
public:
void powerOn() override {
cout << "power on" << endl;
}
void powerOff() override {
cout << "power off" << endl;
}
void chargeBattery() override {
cout << "charging battery" << endl;
}
void takePhoto() override {
cout << "clicking photo" << endl;
}
};
int main() {
Phone *phone = new Phone();
Camera *camera = new Camera();
return 0;
}