-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWaterSensor.java
52 lines (41 loc) · 1.1 KB
/
WaterSensor.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
44
45
46
47
48
49
50
51
52
// This class represents the Water sensor class in the wireless security system.
public class WaterSensor extends SecurityDevice {
public static String deviceID = "watersensor";
// current water level
private int waterLevel;
// Initial values for WaterSensor.
public WaterSensor() {
super(deviceID);
waterLevel = 0;
}
// Sets water level to be tested
public void setWaterLevel(int level) {
waterLevel = level;
}
// Getter for Water Level
public int getWaterLevel() {
return waterLevel;
}
// Private method that checks for correct water level. 50 is the threshold!
private boolean checkWaterLevel() {
if (waterLevel > 50) {
return true;
} else {
return false;
}
}
// Sends Water Sensor Messages.
public void sendAlert() {
if (checkWaterLevel() && isOn) {
super.sendAlert("ALERT! WATER ISSUE DETECTED!", deviceID);
} else {
super.sendAlert("Water Sensor detects no problems.", deviceID);
}
}
public void sendMessage() {
}
// resets Water Sensor to initial values.
public void reset() {
waterLevel = 0;
}
}