Python
- 1 ответ
- 0 вопросов
0
Вклад в тег
class Counter:
def __init__(self, number=5, lower_limit=3, upper_limit=10):
assert lower_limit <= number <= upper_limit
self.count = [*range(1, number+1)]
self.lower_limit = lower_limit
self.upper_limit = upper_limit
def increase_count(self):
if len(self.count) == self.upper_limit:
raise ValueError("upper_limit is reached")
self.count.append(self.count[-1] +1)
return self.count
def decrease_count(self):
if len(self.count) == self.lower_limit:
raise ValueError("lower_limit is reached")
self.count.pop()
return self.count
obj = Counter()
print(obj.increase_count())
print(obj.increase_count())
print(obj.increase_count())
print(obj.decrease_count())
print(obj.decrease_count())