public class CounterWithMax { public int Count; public int Max; public bool TryIncrease() { if (!CanIncrease()) return false; Count += 1; return true; } public bool CanIncrease() => Count < Max; public void Decrease() => Count -= 1; public CounterWithMax(int initial, int max) { Count = initial; Max = max; } }
801000cookie-checkC# Counter with max