I have always found it annoying that the exercism specifications
do not spell things out, so you HAVE to read the tests to find out
what you are supposed to do, which pretty much spoils the point of
them BEING tests.
In this case, we note that there is a test case where the number
of hours is 100, and it is to be accepted as meaning '04'.
There is also a test case where the number of minutes is 160
and it is to be taken as 40 minutes plus 2 hours.
So the only way you can pass the tests is something like
class methods for: 'instance creation'
hours: h minutes: m
^self new setMinutesSinceMidnight: (h * 60 + m bitOr: 0) \\ 1440
methods for: 'private'
minutesSinceMidnight := m.
methods for: 'accessing'
^minutesSinceMidnight // 60
^minutesSinceMidnight \\ 60
The only *checking* that is involved is that the hour and minute counts must be integers, which I used " bitOr: 0" to do. What's the best way to do thisE?
As for where to do checking in general,
put it as close to the encapsulation boundary as you reasonably can.
If there is a PUBLIC method for changing the time on a Clock,
you need to put the checking in that method. If (as here) a clock value
is supposed to be immutable, put it in the instance creation method.