prog11_21.py

# ここまでにCounterクラスが定義されるようにする

class VerboseCounter(Counter):
    def count(self, incr=1):
        super().count(incr)
        print(f"{self.value}になりました")

    def reset(self):
        super().reset()
        print("リセットしました!")

counter = VerboseCounter()
counter.reset()
for _ in range(3):
    counter.count()
counter.count(1000)
counter.reset()

# プログラム11-21(VerboseCounterクラス)