Package com.zybooks.dsaj.primer
Class Counter
java.lang.Object
com.zybooks.dsaj.primer.Counter
An integer counter that can be incremented and reset to zero.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
Counter
public Counter()Constructs a new Counter with value zero. -
Counter
public Counter(int initial) Constructs a new Counter with given initial value.- Parameters:
initial
- the initial value
-
-
Method Details
-
getCount
public int getCount()Returns the current count.- Returns:
- the current count
-
increment
public void increment()Increments the count by one. -
increment
public void increment(int delta) Increments the count by the specified delta.- Parameters:
delta
- the amount of the increment
-
reset
public void reset()Returns the count to zero.
-