add coffee maker
This commit is contained in:
@ -1,108 +0,0 @@
|
||||
# containment vessel
|
||||
|
||||
class Pot:
|
||||
def __init__(self):
|
||||
self.has_pot = True
|
||||
self.has_coffee = False
|
||||
self.warming_plate_on = False
|
||||
self.is_brewing = False
|
||||
|
||||
def is_ready(self):
|
||||
return self.has_pot
|
||||
def start(self):
|
||||
self.is_brewing = True
|
||||
|
||||
def pause(self):
|
||||
if self.
|
||||
self.warming_plate_on = False
|
||||
|
||||
def resume(self):
|
||||
if self.has_coffee:
|
||||
self.warming_plate_on = True
|
||||
|
||||
def done(self):
|
||||
self.is_brewing = False
|
||||
|
||||
# hot water source
|
||||
class WaterSource:
|
||||
def __init__(self):
|
||||
# default to false later
|
||||
self.has_water = True
|
||||
self.boiler_on = False
|
||||
self.valve_open = True
|
||||
def is_ready(self):
|
||||
# "NotEmpty" = True
|
||||
return self.has_water
|
||||
|
||||
def boiling(self):
|
||||
return self.boiler_on
|
||||
|
||||
def start(self):
|
||||
self.boiler_on = True
|
||||
self.valve_open = False
|
||||
|
||||
def pause(self):
|
||||
self.valve_open = True
|
||||
self.boiler_on = False
|
||||
|
||||
def resume(self):
|
||||
self.valve_open = False
|
||||
self.boiler_on = True
|
||||
|
||||
def done(self):
|
||||
self.boiler_on = False
|
||||
self.valve_open = True
|
||||
|
||||
|
||||
class CoffeeMaker:
|
||||
def __init__(self):
|
||||
self.pot = Pot()
|
||||
self.water_source = WaterSource()
|
||||
self.brew_light = False
|
||||
|
||||
def push_brew_button(self):
|
||||
self.brew()
|
||||
def remove_pot(self):
|
||||
self.pot.has_pot = False
|
||||
def add_water(self):
|
||||
self.water_source.has_water = True
|
||||
def poll(self):
|
||||
# is pot on warmer plate
|
||||
if self.pot.is_ready():
|
||||
if self.water_source.boiling():
|
||||
self.pot.has_coffee = True
|
||||
self.water_source.valve_open = False
|
||||
# does pot have coffee
|
||||
if self.pot.has_coffee:
|
||||
self.pot.warming_plate_on = True
|
||||
else:
|
||||
self.pot.warming_plate_on = False
|
||||
#
|
||||
if not self.water_source.has_water:
|
||||
self.water_source.done()
|
||||
self.brew_light = True
|
||||
|
||||
if not self.water_source.has_water and not self.pot.has_coffee and self.pot.is_brewing:
|
||||
self.pot.done()
|
||||
self.brew_light = False
|
||||
else:
|
||||
self.water_source.valve_open = True
|
||||
self.pot.has_coffee = False
|
||||
|
||||
|
||||
def brew(self):
|
||||
if not self.pot.is_ready() or not self.water_source.is_ready():
|
||||
return False
|
||||
|
||||
self.pot.start()
|
||||
|
||||
while self.water_source.boiling():
|
||||
self.poll()
|
||||
|
||||
while self.pot.has_coffee():
|
||||
self.poll()
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user