-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDevice.h
51 lines (42 loc) · 1.08 KB
/
Device.h
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
#pragma once
#include <cstdlib>
#include <ctime>
#include <string>
using std::string;
class Device {
const int watt; // ¿ÍÆ®
bool power; // ÄÑÁü¿©ºÎ
static string name;
protected:
Device(int power, int watt) : power(power), watt(watt) {}
public:
bool getPower() const { return power; }
void setPower(bool value) { power = value; }
int getWatt() const { return watt; }
string getOnString() const { return power ? "ON" : "OFF"; }
};
class Light : public Device {
public:
const static int WATT = 40;
Light(bool power = false) : Device(power, WATT) {}
};
class AirConditioner : public Device {
public:
const static int WATT = 1300;
AirConditioner(bool power = false) : Device(power, WATT) {}
};
class TV : public Device {
public:
const static int WATT = 300;
TV(bool power = false) : Device(power, WATT) {}
};
class Computer : public Device {
public:
const static int WATT = 80;
Computer(bool power = false) : Device(power, WATT) {}
};
class Equipment : public Device {
public:
const static int WATT = 40;
Equipment(bool power = false) : Device(power, WATT) {}
};