Countdown

  • 9
  • Locked
1. Figure out what the program does. 2. Implement logic in the printCountdown method so that every half a second the program displays an object from the variable list. The output should be in reverse order: from the index passed to Countdown down to zero. Example: Index 3 is passed Example console o
You can't complete this task, because you're not signed in.
Comments (10)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
aijo
Level 30 , Germany, Germany
10 February 2022, 19:06
Does anyone understand why countFrom is being decreased first, before the print? Index 3 is being passed, but the print starts from index 2. Am I the only one confused about this?
Felix
Level 19
8 April 2020, 22:48
I don't see what's wrong with my code:
public void printCountdown() throws InterruptedException {
            while (countFrom > 0) {
                countFrom--;
                System.out.println(list.get(countFrom));
                Thread.sleep(500);
            }
        }
At validation I get these two errors: The printCountdown method should reduce (decrement) the value of the variable countFrom. The printCountdown method must display the list item with an index equal to the new value of countFrom.
Angel Li
Level 18 , Fremont, United States
20 July 2020, 18:04
You don't need the while loop, it's already in the run method.
Switch/Cypher
Level 25 , Bexleyheath, United Kingdom
28 September 2020, 15:03
Yeah sure, that's true. Still though, validator shouldn't fail on those conditions.....
Roman Grygorczuk
Level 19 , Cracow, Poland
3 January 2021, 19:02
I believe they want to see your code as simple as possible
remote87
Level 18 , Sofia, Bulgaria
4 March 2021, 11:49
Yooohoooo, thank you, Angel!!!
Alexandre Lalancette
Level 41 , Quebec, Canada
19 November 2019, 15:24
Don't forget the .join() method ;)
Seferi
Level 22 , United Federation of Planets
12 September 2020, 19:48
Why .join() ?
Roman Grygorczuk
Level 19 , Cracow, Poland
3 January 2021, 19:00
I didn't get it too...
Lex Icon
Level 17 , Sofia, Bulgaria
25 February 2021, 15:47
Join() isn't necessary here.