Class Counter

Object
Counter

public class Counter extends Object
A simple counter that increments.

This is useful when an object on the heap is required to track counting.

Author:
Owen Feehan
  • Constructor Details

    • Counter

      public Counter(int count)
      Creates a new Counter 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.