-
Notifications
You must be signed in to change notification settings - Fork 2
/
SmokeDetector.java
43 lines (36 loc) · 1.16 KB
/
SmokeDetector.java
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
// This class represents the Smoke Detecotr class in the wireless security system.
public class SmokeDetector extends SecurityDevice {
// The device ID of the hardware.
public static final String deviceID = "SmokeDetector";
private static int mySmokeLevel;
private static final int mySmokeThreshold = 50;
private static boolean isArmed;
public SmokeDetector() {
super(deviceID);
mySmokeLevel = 0;
isArmed = true;
}
public int getSmokeLevel() {
return mySmokeLevel;
}
public void armDevice(boolean isArmed) {
if (isArmed) {
System.out.println("Smoke Sensor armed.");
} else {
System.out.println("Smoke Sensor disarmed.");
}
}
public void sendAlert() {
if (isArmed && (mySmokeLevel > mySmokeThreshold)) {
super.sendAlert("ALERT! SMOKE DETECTED!", deviceID);
} else {
super.sendAlert("No Smoke Detected", deviceID);
}
}
public void setSmokeLevel(int level){
this.mySmokeLevel = level;
}
// Method that sends a message to the MobileNumber class.
void SendMessage() {
}
}