Iv'e tried so many different things and I cannot pass everything at once. I change things and pass what's not here, but something else fails. I'm loosing my mind here, please help.
package com.codegym.task.task16.task1617;
/*
*/
import java.time.Instant;
import java.util.Calendar;
import java.util.Date;
public class Solution {
public static volatile int numSeconds = 4;
public static void main(String[] args) throws InterruptedException {
RacingClock clock = new RacingClock();
//write your code here
Thread.sleep(3500);
clock.interrupt();
}
public static class RacingClock extends Thread {
public RacingClock() {
start();
}
public void run() {
//write your code here
if(numSeconds == 3) {
while (true) {
try {
System.out.print(numSeconds + " ");
Thread.sleep(1000);
numSeconds--;
if (numSeconds == 1) {
System.out.print("Go!");
break;}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}else if(numSeconds == 4 ){
while (true) {
try {
if (numSeconds < 0.5) {
System.out.print("Interrupted!");
break;
}
System.out.print(numSeconds + " ");
numSeconds--;
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
}