package counters;
/**
*
* Provides a counter interface.
*
*
*
* Interface Invariant: *
*limit
is a positive integer that can be
* represented exactly using Java’s int
* data type
* value
is an integer whose value is between
* 0
and limit−1
(inclusive)
* * Additional Notes: *
* *
* A constructor should be provided that allows a counter with
* a given positive integer limit
to be created.
* The default initial valuex
should be zero.
*
limit
.
* limit
limit
of this counter
*
*/
int getLimit ();
/**
*
* Accessor method used to display the counter’s
* current value
.
* value
value
of this counter
*
*/
int getValue ();
// Mutator Method
/**
*
* Mutator method to increment the counter’s
* value
.
* value < limit−1
limit
is not changed
* (so that it is still a postive integer that can be
* represented exactly using Java’s int
* data type). value
is v, then
* the final value is equal to v+1
* (which is an integer between 0
* and limit−1
, as required) value = limit−1
limit
is not changed
* (so that it is still a positive integer that can be
* represented exactly using Java’s int
* data type). limit
= 0. LimitReachedException
is thrown. value
is at
* its maximal value when this method is applied
*
*/
public void advanceValue () throws LimitReachedException;
}