Skip to content
Snippets Groups Projects
Commit c7e2506b authored by John Doe's avatar John Doe
Browse files

Tâche 2(realising clock)

parent ac3f79fc
Branches develop
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
......@@ -8,12 +8,42 @@ public class Main {
public static void main(String[] args) throws InterruptedException {
Ticker ticker = new Ticker();
ticker.add(new Tickable() {
int hour = 0;
int minute = 0;
int second = 0;
@Override
public void notifyTick() {
// TODO Auto-generated method stub
System.out.println("tic");
if (second <=59){
System.out.printf("%02d:%02d:%02d%n", hour,minute,second);
second = second +1;
}
else{
second = 0;
minute = minute + 1;
if(minute<=59){
System.out.printf("%02d:%02d:%02d%n", hour,minute,second);
}
else{
minute = 0;
hour = hour + 1;
if (hour <= 23) {
System.out.printf("%02d:%02d:%02d%n", hour,minute,second);
}
else{
hour = 0;
System.out.printf("%02d:%02d:%02d%n", hour,minute,second);
}
}
second = second + 1;
}
}
});
ticker.startTicking();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment