计数器Counter
代码示例
class Counter(object):
"""Models a counter。"""
# Class variable
instance = 0
# Constructor
def __init__(self):
"""Sets up the counter"""
Counter.instance += 1
self.reset() # 初始化对象,
# Mutator methods # 修改器
def reset(self):
"""Sets the Counter to 0"""
self._value = 0
def increment(self, amount