//However when he, the Spirit of truth, has come, he will guide you into all truth, for he will not speak from himself; but whatever he hears, he will speak. He will declare to you things that are coming.(John 16:13) package com.javarush.task.task16.task1613; /* 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 e) { } } 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)); } try{ Thread.sleep(1000); }catch (InterruptedException e) {e.printStackTrace();} if (seconds <= 58) {seconds++;} else if (seconds == 59) {seconds = 0; if (minutes <= 58) {minutes++;} else if (minutes == 59) {minutes = 0; if (hours<= 22) {hours++;} else if (hours == 23) {hours = 0;} } } } } } /* Big Ben clock 1. РазбеÑиÑÑ, ÑÑо Ð´ÐµÐ»Ð°ÐµÑ Ð¿ÑогÑамма. 2. РеализÑй Ð»Ð¾Ð³Ð¸ÐºÑ Ð¼ÐµÑода printTime Ñак, ÑÑÐ¾Ð±Ñ ÐºÐ°Ð¶Ð´ÑÑ ÑекÑÐ½Ð´Ñ Ð²ÑдавалоÑÑ Ð²ÑÐµÐ¼Ñ Ð½Ð°ÑÐ¸Ð½Ð°Ñ Ñ ÑÑÑановленного в конÑÑÑÑкÑоÑе ÐÑимеÑ: Рг. Ðондон ÑейÑÐ°Ñ 23:59:58! Рг. Ðондон ÑейÑÐ°Ñ 23:59:59! Рг. Ðондон ÑейÑÐ°Ñ Ð¿Ð¾Ð»Ð½Ð¾ÑÑ! Рг. Ðондон ÑейÑÐ°Ñ 0:0:1! ТÑебованиÑ: 1.âÐеÑод printTime должен ÑабоÑаÑÑ Ð¿ÑимеÑно ÑекÑндÑ. 2.âÐеÑод printTime должен ÑвелиÑиваÑÑ (инкÑеменÑиÑоваÑÑ) колиÑеÑÑво ÑекÑнд, Ñ Ñанимое в пеÑеменной seconds. 3.âСекÑнд, поÑле икÑеменÑиÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ð²Ñемени, не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ð±Ð¾Ð»ÑÑе 59. Ðолжно ÑвелиÑиÑÑÑÑ ÐºÐ¾Ð»Ð¸ÑеÑÑво минÑÑ. 4.âÐинÑÑ, поÑле икÑеменÑиÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ð²Ñемени, не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ð±Ð¾Ð»ÑÑе 59. Ðолжно ÑвелиÑиÑÑÑÑ ÐºÐ¾Ð»Ð¸ÑеÑÑво ÑаÑов. 5.âЧаÑов, поÑле икÑеменÑиÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ð²Ñемени, не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ð±Ð¾Ð»ÑÑе 23. package com.javarush.task.task16.task1613; * 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 e) { } } private void printTime() throws InterruptedException { //add your code here - Ð´Ð¾Ð±Ð°Ð²Ñ ÐºÐ¾Ð´ ÑÑÑ 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)); } } } } */