# SPDX-License-Identifier: MIT
# Independently authored construction, sharing, inheritance and lookup observations.
class Counter:
    label = "counter"
    def __init__(self, value=0):
        self.value = value
    def increment(self, step=1):
        self.value += step
        return self.value
    def __str__(self):
        return self.label + ":" + str(self.value)
    def __bool__(self):
        return self.value != 0

class FastCounter(Counter):
    def increment(self, step=1):
        return super().increment(step * 2)

first = Counter(5)
alias = first
second = Counter()
fast = FastCounter(10)
print(first is alias, first is second, first == alias, first != second)
print(alias.increment(3), first.value, second.value)
print(fast.increment(), Counter.increment(fast, 3), fast.value)
print(first, second, fast)
print(bool(first), bool(second), not second)
Counter.label = "updated"
print(first.label, second.label, fast.label, Counter.label)
first.label = "own"
print(first.label, second.label)
print(isinstance(fast, Counter), isinstance(first, FastCounter), isinstance(first, object))
print(issubclass(FastCounter, Counter), issubclass(Counter, FastCounter))

def receiver():
    print("receiver", end=":")
    return first

def amount():
    print("amount", end=":")
    return 4

receiver().value += amount()
print(first.value)
