Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Microwave Ovens by xivanity
from datetime import datetime, timedelta
import time
class MicrowaveBase:
def __init__(self):
pass
class Microwave1(MicrowaveBase):
def show_time(self, time):
if time.seconds > 5400:
time = timedelta(seconds=5400)
ret = f'{time.seconds//60:0>2}' + ':' + f'{time.seconds%60:0>2}'
return '_' + ret[1:]
class Microwave2(MicrowaveBase):
def show_time(self, time):
if time.seconds > 5400:
time = timedelta(seconds=5400)
ret = f'{time.seconds//60:0>2}' + ':' + f'{time.seconds%60:0>2}'
return ret[:-1] + '_'
class Microwave3(MicrowaveBase):
def show_time(self, time):
if time.seconds > 5400:
time = timedelta(seconds=5400)
ret = f'{time.seconds//60:0>2}' + ':' + f'{time.seconds%60:0>2}'
return ret
class RemoteControl:
def __init__(self, mw):
self.mw = mw
fmt = '%M:%S'
self.time = timedelta(seconds=0)
def set_time(self, t):
fmt = '%M:%S'
self.time = timedelta(minutes=int(t[:2])) + timedelta(seconds=int(t[-2:]))
def add_time(self, d):
if d[-1] == 's':
d = int(d[:-1])
else:
d = int(d[:-1])*60
self.time += timedelta(seconds=d)
def del_time(self, d):
if d[-1] == 's':
d = int(d[:-1])
else:
d = int(d[:-1])*60
self.time -= timedelta(seconds=d)
self.time = max(self.time, timedelta(seconds=0))
def show_time(self):
return self.mw.show_time(self.time)
Jan. 30, 2019