diff --git a/lab36.py b/lab36.py new file mode 100644 index 0000000..e8484be --- /dev/null +++ b/lab36.py @@ -0,0 +1,32 @@ +class Stack: + def __init__(self): + self.__stack_list = [] + + def push(self, val): + self.__stack_list.append(val) + + def pop(self): + val = self.__stack_list[-1] + del self.__stack_list[-1] + return val + +class CountingStack(Stack): + def __init__(self): + Stack.__init__(self) + self.__j = 0 + + def get_counter(self): + return self.__j + + def pop(self): + self.__j += 1 + return Stack.pop(self) + + +stk = CountingStack() + +for i in range(100): + stk.push(i) + stk.pop() + +print(stk.get_counter()) \ No newline at end of file