-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lab_solution_35.cpp
56 lines (50 loc) · 1.32 KB
/
Lab_solution_35.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
#include <iostream>
#include <string>
using namespace std;
class Device
{
public:
std::string getModel()
{
return m_model;
}
int getSystemID()
{
return m_systemID;
}
void setModel(std::string const model) { m_model = model; }
void setSystemID(int systemID) { m_systemID = systemID; }
protected:
std::string m_model;
private:
int m_systemID = 0;
};
class Lightbulb : public Device
{
public:
bool getBrightness()
{
return m_brightness;
}
void setColor(int hexColor)
{
cout << "Lightbulb color is 0x"<< std::hex << hexColor << endl;
}
void setColor(int red, int green, int blue)
{
cout << "Lightbulb color is "<< "RGB("<< red <<"," <<green <<"," <<blue << ")" << endl;
}
void setColor(int cyan, int magenta, int yellow, int black)
{
cout << "Lightbulb color is "<< "CMYK("<< cyan <<"," <<magenta <<"," <<yellow <<"," <<black << ")" << endl;
}
private:
int m_brightness;
};
int main()
{
Lightbulb myLightBulb;
myLightBulb.setColor(0x3DB7E4);
myLightBulb.setColor(61, 183, 228);
myLightBulb.setColor(68, 3, 0, 0);
}