package com.example.stimulus; import com.example.notification.Notification; import com.example.notification.SedentaryNotification; import com.example.stimulusStrategy.StimulusStrategy; import java.util.Observable; /** * Created by pharmacy on 09/01/2018. */ class SedentaryStimulus implements Stimulus { private StimulusStrategy strategy; public SedentaryStimulus(){ chooseStrategy(null); } public SedentaryStimulus(StimulusStrategy s){ chooseStrategy(s); } public Notification createNotification() { Notification notification = new SedentaryNotification(); //Either further define this notification here or change to one line; return notification; } public void chooseStrategy(StimulusStrategy s) { if(s != null){ strategy = s; } else{ strategy = defaultStrategy; } strategy.addObserver(this); } @Override //Called by notify and will create Notification if required then send public void update(Observable observable, Object o) { //If a condition - such as time elapsed since last notification or not night time Notification notification = createNotification(); notification.send(); } }