Java

Digital Clock 3

8 points

This program is a final improvement of your digital clock program. This program assumes that you've completed Digital Clock 2. Use your Digital Clock 2 program as the basis for Digital Clock 3.

In #3, the beepers you put down serve as a digital clock, but an accurate clock. That is, let's say it's 9:17 when you run it. When the actual time updates to 9:18, your KarelJRobot screen will erase and the new correct time will be drawn. When the time updates to 9:19, your digital clock will again update to the correct time.

You can use an integer 'minuteDrawn' to allow your program to know when to delete the displayed time and redraw it. 'minuteDrawn' keeps track of the minute that is currently displayed on the screen. When you redraw the time, you need to update 'minuteDrawn'.

A basic section is a while loop or do - while loop. I used a do - while loop, which is set up like this:
do
{
   Java statements here
} while(true);

Inside the loop, you should re-create the Calendar object and read the current hour and minute from the computer clock.

Also inside the loop is an IF statement. The IF statement should not run as long as 'minuteDrawn' is equal to the current minute from the computer clock. The IF statement should run as soon as 'minuteDrawn' differs from the current minute. Inside the IF statement should be 'World.reset()' and 'World.setSize()'. Also inside the IF statement, create the 5 robots and have them draw the current time.