From 789d70c7e5cf84fce09d8e0c1f8a754dee95bf37 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Mon, 30 Mar 2026 05:31:03 +0000 Subject: [PATCH] Added simple Counter in counter.py Co-authored-by: dzianisv --- counter.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 counter.py diff --git a/counter.py b/counter.py new file mode 100644 index 0000000..cb776fe --- /dev/null +++ b/counter.py @@ -0,0 +1,20 @@ +class Counter: + """ + Simple counter with increment, decrement, and value retrieval. + """ + def __init__(self, initial: int = 0): + self._value = int(initial) + + def increment(self, amount: int = 1) -> int: + """Increase the counter by 'amount' (default 1) and return new value.""" + self._value += int(amount) + return self._value + + def decrement(self, amount: int = 1) -> int: + """Decrease the counter by 'amount' (default 1) and return new value.""" + self._value -= int(amount) + return self._value + + def get_value(self) -> int: + """Return the current value of the counter.""" + return self._value