📄 securityzone.java~5~
字号:
package securitysystem;
public abstract class SecurityZone {
private SecurityZone parent;
private String name;
public void SecurityZone(String name)
{
this.name=name;
}
//Return this object's parent zone.
SecurityZone getParent() {
return parent;
} // getParent()
/**
* Call this method to notify this zone of a new sensor
* measurement.
*/
void notify(int measurement, Sensor sensor) {
if (!handleNotification (measurement, sensor)&& parent != null) {
parent.notify (measurement, sensor);
} // if
}
/**
* This method is called by the notify method so that
* this object can have a chance to handle measurements.
*/
abstract boolean handleNotification(int measurement,
Sensor sensor);
/**
* This method is called by a child zone to report a fire.
* It is expected that the child zone has turned on
* sprinklers or taken other measures to control the fire
* within the child zone. The purpose of this method is to
* be overridden by subclasses so it can take any
* necessary actions outside of the child zone.
*/
void fireAlarm(SecurityZone zone) {
// Turn on sprinklers
System.out.println(this.name+"true on the sprinkles in"+zone.name);
if (parent != null)
parent.fireAlarm(zone);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -