Skip to content
Snippets Groups Projects
Select Git revision
  • 922b5ac7f559098ac307a75f6e45964b30008c02
  • master default protected
2 results

ShutdownAlarm.java

Blame
  • Forked from NAVES Guyslain / clock-template
    8 commits ahead of the upstream repository.
    Hp's avatar
    ADAMOU Salim authored
    modification de la classe  Alarm.java avec l'ajout d'une class ShutdownAlarm.java qui etend alarm et qui utilise Ticker.
    922b5ac7
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ShutdownAlarm.java 812 B
    package fr.univamu.l2mi;
    
    
    import fr.univamu.l2mi.ticker.Alarm;
    import fr.univamu.l2mi.ticker.Ticker;
    
    public class ShutdownAlarm extends Alarm {
        private final Ticker ticker;
    
        public ShutdownAlarm(Ticker ticker) {
            super();
            this.ticker = ticker;
        }
    
        @Override
        public void notifyTick() {
            super.notifyTick();
    
            // Ajoutez une condition pour vérifier si l'alarme doit éteindre le Ticker
            if (shouldShutdown()) {
                System.out.println("ShutdownAlarm: Arrêt de l'horloge.");
                stopTicker();
            }
        }
    
        protected boolean shouldShutdown() {
            return getCounter() >= 30;
        }
    
        //  arrêter le Ticker
        protected void stopTicker() {
            System.out.println("Ticker arrêté.");
            ticker.stopTicking();
        }
    }