Define a 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.
Your count
property should be publicly readable but not publicly writable.
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: