Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
second solution in Clear category for Microwave Ovens by thealfest1
class MicrowaveBase:
pass
class Microwave1(MicrowaveBase):
pass
class Microwave2(MicrowaveBase):
pass
class Microwave3(MicrowaveBase):
pass
class RemoteControl:
def __init__(self, oven):
self.oven = oven
self.time = '00:00'
def set_time(self, time):
self.time = time
self.add_time('0s')
def add_time(self, time, sign = 1):
d = int(time[:-1]) * sign * (60 if time[-1:] == 'm' else 1)
time = self.str2time() + d
self.time2str(90 * 60 if time > 90 * 60 else 0 if time < 0 else time)
def del_time(self, time):
self.add_time(time, -1)
def show_time(self):
if type(self.oven) is Microwave1:
return '_' + self.time[1:]
if type(self.oven) is Microwave2:
return self.time[:-1] + '_'
else:
return self.time
def time2str(self, time):
self.time = ':'.join((('00' + str(t))[-2:]) for t in divmod(time, 60))
def str2time(self):
return int(self.time[-2:]) + int(self.time[:2])*60
Jan. 7, 2019
Comments: