Created
June 27, 2018 03:03
-
-
Save ThanawatMas/7b671fd47d29aaf982be280d804c8c02 to your computer and use it in GitHub Desktop.
Monitor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AskMonitor am = new AskMonitor("Time Vortex Hocus", 2, alarm); | |
am.setValue(3); | |
if (am.getValue() > am.getLimit()) | |
am.getAlarm().warn(am.getName() + " too high"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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