Skip to content

Commit

Permalink
Update syntax for constants
Browse files Browse the repository at this point in the history
  • Loading branch information
megabyde committed Jan 21, 2024
1 parent 6b2f8ad commit 30db5cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@


class Alarm:
LOW_PRESSURE_THRESHOLD = 17
HIGH_PRESSURE_THRESHOLD = 21

def __init__(self):
self._low_pressure_threshold = 17
self._high_pressure_threshold = 21
self._sensor = Sensor()
self._is_alarm_on = False

def check(self):
psi_pressure_value = self._sensor.pop_next_pressure_psi_value()
if (psi_pressure_value < self._low_pressure_threshold
or self._high_pressure_threshold < psi_pressure_value):

if (psi_pressure_value < self.LOW_PRESSURE_THRESHOLD
or psi_pressure_value > self.HIGH_PRESSURE_THRESHOLD):
self._is_alarm_on = True

@property
Expand Down
2 changes: 1 addition & 1 deletion sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Sensor:

def pop_next_pressure_psi_value(self):
pressure_telemetry_value = self.sample_pressure()
return Sensor.OFFSET + pressure_telemetry_value
return self.OFFSET + pressure_telemetry_value

@staticmethod
def sample_pressure():
Expand Down

0 comments on commit 30db5cb

Please sign in to comment.