Skip to content
Snippets Groups Projects
Commit 97c4aa3f authored by salma-lti's avatar salma-lti
Browse files

Tâche 8

parent bf83ae28
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ public class PrintAlarm implements Tickable{
int hours_c = 0;
boolean reached = false;
int seconds_since = 0;
int max_seconds = 60;
public PrintAlarm(int seconds_c,int minutes,int hours){
this.seconds = seconds_c;
......@@ -38,7 +39,7 @@ public class PrintAlarm implements Tickable{
if (reached){
seconds_since++;
System.out.println(hours_c +":"+minutes_c+":"+seconds_c);
if (seconds_since==60){
if (seconds_since==max_seconds){
reached = false;
seconds_since = 0;
}
......
package fr.univamu.l2mi.ticker;
public class StopClock extends PrintAlarm{
int duration;
Ticker ticker;
public StopClock(int seconds_c, int minutes, int hours, Ticker ticker, int duration) {
super(seconds_c, minutes, hours);
this.duration = duration;
this.ticker = ticker;
this.max_seconds= duration + 1;
}
@Override
public void notifyTick() {
super.notifyTick();
if(seconds_since == duration){
ticker.stopTicking();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment