Skip to content

Instantly share code, notes, and snippets.

@ThanawatMas
Created June 27, 2018 03:03
Show Gist options
  • Save ThanawatMas/7b671fd47d29aaf982be280d804c8c02 to your computer and use it in GitHub Desktop.
Save ThanawatMas/7b671fd47d29aaf982be280d804c8c02 to your computer and use it in GitHub Desktop.
Monitor
AskMonitor am = new AskMonitor("Time Vortex Hocus", 2, alarm);
am.setValue(3);
if (am.getValue() > am.getLimit())
am.getAlarm().warn(am.getName() + " too high");
public class Monitor {
private int value;
private int limit;
private boolean isTooHigh;
private String name;
private Alarm alarm;
public Monitor(String name, int limit, Alarm alarm) {
this.name = name;
this.limit = limit;
this.alarm = alarm;
}
public int getValue() {return value;}
public void setValue(int arg) {value = arg;}
public int getLimit() {return limit;}
public String getName() {return name;}
public Alarm getAlarm() {return alarm;}
}
...
public void setValue(int arg) {
value = arg;
if (value > limit) alarm.warn(name + " too high");
}
...
TellMonitor tm = new TellMonitor("Time Vortex Hocus", 2, alarm);
tm.setValue(3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment