Всем привет. У меня в 57 строке стоит условие выхода из рекурсии. Кроме того, работает программа ровно так и ровно столько, как написано в условии, если я опять не проглядел что-то. Других причин почему моё решение не принимается я не получаю.
Кто чем может, сориентируйте в чём может быть ошибка?
package com.javarush.task.jdk13.task16.task1621;
/*
Big Ben clock
*/
public class Solution {
public static volatile boolean isStopped = false;
public static void main(String[] args) throws InterruptedException {
Clock clock = new Clock("Лондон", 23, 59, 57);
Thread.sleep(4000);
isStopped = true;
Thread.sleep(1000);
}
public static class Clock extends Thread {
private String cityName;
private int hours;
private int minutes;
private int seconds;
public Clock(String cityName, int hours, int minutes, int seconds) {
this.cityName = cityName;
this.hours = hours;
this.minutes = minutes;
this.seconds = seconds;
start();
}
public void run() {
try {
while (!isStopped) {
printTime();
}
} catch (InterruptedException ignore) {
}
}
private void printTime() throws InterruptedException {
if (hours == 0 && minutes == 0 && seconds == 0) {
System.out.println(String.format("В г. %s сейчас полночь!", cityName));
} else {
System.out.println(String.format("В г. %s сейчас %d:%d:%d!", cityName, hours, minutes, seconds));
}
Thread.sleep(1000);
if (seconds < 59) ++seconds;
else {
seconds = 00;
if (minutes < 59) ++minutes;
else {
minutes = 00;
if (hours < 23) ++hours;
else hours = 00;
}
}
if (!isStopped) printTime();
}
}
}