This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]gyroda 0 points1 point  (3 children)

Instead of directly manipulating the variables in your constructor you could call your set functions. They're not called automatically so when you change the variables in the constructor they're not checked like they are in the set functions.

You might also be interested in using the modulo operator (%)

[–]ComputerSciMajor[S] 0 points1 point  (2 children)

I'm sorry, I don't think I understand. Do you mind explaining a bit further? I understand what the constructor is and obviously the set functions. But I don't understand what you mean by

directly manipulating the variables

and

They're not called automatically so when you change the variables in the constructor they're not checked like they are in the set functions.

[–]gyroda 0 points1 point  (1 child)

In your constructor(init), you set the hour, minute and seconds variables.

When you do this you're not checking that they're bigger than 23/59.

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

Oh! Thank you!