Define a public class
named EvenCounter
.
It should have a public instance method named addValue
taking a single int
argument.
If the argument passed to addValue
is even, it increments the count stored by the counter.
addValue
does not return a value.
You should provide a getter for the count getCount
.
Your class should also provide a constructor taking a single int
argument that sets the initial count, which
you should assert
is non-negative.
Your class should not allow modifications to the count
except using the addValue
method.
When you are finished your class should work as follows:
You're challenge is to write tests for this problem described above.
Stuck? You may find these lessons helpful: