Op 1-9-2020 om 21:40 schreef Roelof
Wobben:
Op
1-9-2020 om 21:11 schreef Richard Sargent:
You will discover an error when you write
your tests, but that's fine. It's why you write tests. :-)
#validateTime:minute: is a poor name choice for a few reasons.
- there is no validation going on. Validation would report an
error for invalid data.
- there is nothing to suggest what the first argument is, the
counterpart to "minute:".
- it doesn't suggest there will be a new Time ("Clock") created.
- it's a "verb phrase" saying it will *do* something rather than
answer something (I'm being vague here. Sorry.)
I suggest #normalizedForHour:minute:.
It explains that it will normalize the values and that it will
answer a normalized result (it still isn't great, as it doesn't
explain what).
Perhaps better would be #newNormalizedForHour:minute:.
Thanks,
I think I found the error
and solved it
hour: anInteger minute: anInteger2
������ ^ self new
������ ������ hour: (anInteger2 // 60 + anInteger) % 24;
������ ������ minute: anInteger2 % 60;
������ ������ yourself
instance side :
printOn: aStream
������ ^ aStream
������ ������ nextPutAll: self hour asTwoCharacterString;
������ ������ nextPut: $:;
������ ������ nextPutAll: self minute asTwoCharacterString
and the tests are green
now time to sleep and tomorrow time to figure out how to add and
substract minutes.
As I remember it right you gave already the answer to me somewhere
in our conversation
Roelof
Making it a class method makes things very difficult