Не понимаю что не так с решением
Есть подозрение то что валидатор хочет чтобы я втупую обращался к переменным часы, время и секунды и по условиям инкрементировал
package com.javarush.task.task16.task1613;
/*
Big Ben clock
*/
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
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;
private int totalSec;
public Clock(String cityName, int hours, int minutes, int seconds) {
this.cityName = cityName;
this.hours = hours;
this.minutes = minutes;
this.seconds = seconds;
this.totalSec = hours * minutes * 60 + minutes * 60 + seconds;
start();
}
public void run() {
try {
while (!isStopped) {
printTime();
}
} catch (InterruptedException e) {
}
}
private void printTime() throws InterruptedException {
//add your code here - добавь код тут
Thread.sleep(1000);
totalSec++;
if (totalSec > 86400) totalSec = 0;
hours = totalSec / 3600;
minutes = ( totalSec - ( hours * 3600 ) ) / 60 ;
seconds = totalSec - ( hours * 3600 ) - minutes * 60 ;
if (hours == 0 && minutes == 0 && seconds == 0) {
System.out.println(String.format("В г. %s сейчас полночь!", cityName));
} else {
System.out.println(String.format("В г. %s сейчас %d:%d:%s!", cityName, hours, minutes, seconds < 10 ? "0" + seconds : seconds));
}
}
}
}