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 TypeMethodDescriptionvoid
Decreases the counter by one.int
getCount()
The count, as per current state.void
Increases the counter by one.void
incrementBy
(int value) Increases the counter by a specific value.int
Increases the counter by one, returning the previous value.
-
Constructor Details
-
Counter
public Counter(int count) Creates a newCounter
instance.- 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.
-