You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I found some bug in StopWatch class's run method (Exercise_16_20). The code is:
protected void run() {
if (minute == 59)
hour = hour + 1;
if (second == 59)
minute = minute + 1;
second = second < 59 ? second + 1 : 0;
text.setText(getTime());
}
This code segment will be invoked every second. It means for example, if the minute variable reaches 59, then every second the hour will be incremented (so in 10 second 10 times). The minute variable can be higher than 59, it is also unusual. It can be tested, if you set the Duration.millis to a low value, f.e. to 10ms. I think the code below could work better:
Hi!
I found some bug in StopWatch class's run method (Exercise_16_20). The code is:
This code segment will be invoked every second. It means for example, if the minute variable reaches 59, then every second the hour will be incremented (so in 10 second 10 times). The minute variable can be higher than 59, it is also unusual. It can be tested, if you set the Duration.millis to a low value, f.e. to 10ms. I think the code below could work better:
The same problem is with the method moveClock() in Exercise_15_32 in ClockPane class. It could be modified similarly.
Bye,
Csaba
The text was updated successfully, but these errors were encountered: