Class Counter
Object
Counter
A simple counter that increments.
This is useful when an object on the heap is required to track counting.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDecreases the counter by one.intgetCount()The count, as per current state.voidIncreases the counter by one.voidincrementBy(int value) Increases the counter by a specific value.intIncreases the counter by one, returning the previous value.
-
Constructor Details
-
Counter
public Counter(int count) Creates a newCounterinstance.- Parameters:
count- The count, as per current state.
-
Counter
public Counter()
-
-
Method Details
-
increment
public void increment()Increases the counter by one. -
incrementReturn
public int incrementReturn()Increases the counter by one, returning the previous value.- Returns:
- the value before the increment.
-
incrementBy
public void incrementBy(int value) Increases the counter by a specific value.- Parameters:
value- the value to increase the counter by.
-
decrement
public void decrement()Decreases the counter by one. -
getCount
public int getCount()The count, as per current state.
-