Python, AI, Software Development, Learn Code, Programming.
class Character: def update(self, message): pass class Tom(Character): def update(self, message): print(f"Tom: {message}") class Jerry(Character): def update(self, message): print(f"Jerry: {message}") # Usage cartoon_series = CartoonSeries() tom = Tom() jerry = Jerry() cartoon_series.subscribe(tom)