Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Solution without State Design Pattern solution in Clear category for Multicolored Lamp by von.Oak
class Lamp:
lights = ['Green', 'Red', 'Blue', 'Yellow']
def __init__(self):
self.light_on = -1
def light(self):
self.light_on = (self.light_on + 1) % 4
return self.__class__.lights[self.light_on]
July 14, 2018