Skip to content
Snippets Groups Projects
Commit c841a808 authored by n21223697's avatar n21223697
Browse files

tache2

parent fcc72098
No related branches found
No related tags found
No related merge requests found
Pipeline #26225 failed
package fr.univamu.l2mi;
import fr.univamu.l2mi.ticker.Tickable;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Clock implements Tickable {
private final Date currentTime;
public Clock () {
currentTime = new Date(0);
}
public String getCurrentTime() {
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
return dateFormat.format(currentTime);
}
@Override
public void notifyTick() {
currentTime.setTime(currentTime.getTime() +1000);
System.out.println(getCurrentTime());
}
}
package fr.univamu.l2mi; package fr.univamu.l2mi;
import fr.univamu.l2mi.MyTickable;
import fr.univamu.l2mi.ticker.Ticker;
public class Main { public class Main {
public static void main(String[] args) throws InterruptedException { public static void main(String[] args) throws InterruptedException {
System.out.println("Hello World!"); Ticker ticker = new Ticker();
Clock clock = new Clock();
MyTickable myTickable = new MyTickable(clock);
ticker.add(clock);
ticker.startTicking();
} }
} }
\ No newline at end of file
package fr.univamu.l2mi;
import fr.univamu.l2mi.ticker.Tickable;
public class MyTickable implements Tickable {
private final Clock clock ;
public MyTickable(Clock clock ){
this.clock = clock;
}
@Override
public void notifyTick(){
System.out.println("current time: " + clock.getCurrentTime());
}
}
package fr.univamu.l2mi;
public @interface OveradevoidnotifyTick {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment