Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Microwave Ovens by Moff
class MicrowaveBase(object):
def __init__(self):
self.time = 0
def set_time(self, t):
m, s = map(int, t.split(':'))
self.time = m * 60 + s
def add_time(self, t):
self.time = min(5400, self.time + int(t[:-1]) * (60 if t[-1] == 'm' else 1))
def del_time(self, t):
self.time = max(0, self.time - int(t[:-1]) * (60 if t[-1] == 'm' else 1))
def show_time(self):
return f'{self.time//60:02d}:{self.time%60:02d}'
class Microwave1(MicrowaveBase):
def show_time(self):
return '_' + super().show_time()[1:]
class Microwave2(MicrowaveBase):
def show_time(self):
return super().show_time()[:-1] + '_'
class Microwave3(MicrowaveBase):
pass
class RemoteControl:
def __init__(self, microwave_instance):
self.microwave_instance = microwave_instance
def __getattr__(self, attr):
return getattr(self.microwave_instance, attr)
July 7, 2018